Unicorn's .socket file is not generated successfully

Asked 1 years ago, Updated 1 years ago, 101 views

I am trying to build an environment with sinatra + unicorn + nginx. However, I am having trouble starting unicorn with an error. Please help me.

Environment

  • macosx
    • vagrant
    • centos 6.6
  • vagrant
  • centos 6.6

Error Contents

FATAL--:error adding listener addr=/var/www/html/unicorn/tmp/sockets/unicorn.sock
/var/wwww/html/unicorn/vendor/bundler/ruby/1.9.1/gems/unicorn-4.8.3/lib/unicorn/socket_helper.rb: 158: in `initialize': Operation not permitted -"/var/wwww/html/unicorn/tmp/sockets/unicorno: EPM:

unicorn.rb is as follows:

@dir=File.expand_path("/var/www/html/unicorn",__FILE__)

worker_processes2
working_directory@dir

timeout 300
listen"/var/www/html/unicorn/tmp/sockets/unicorn.sock", —backlog=>1024

pid"#{@dir}/tmp/pids/unicorn.pid"

stderr_path"#{@dir}/log/unicorn.stderr.log"
stdout_path"#{@dir}/log/unicorn.stdout.log"

If you set listen to 3000, it will start well.

I don't know if this .socket file will be created on my own, or if I will prepare and load it myself, but I tried /var/www/html/unicorn/tmp/sockets/ permission, but the result was the same.

Even if I googled, I could only find items that said listen should be the absolute pass, so please let me know. I look forward to your kind cooperation.

ruby nginx unicorn

2022-09-30 15:49

3 Answers

If you set listen to 3000 and so on, it will start well.

I heard that unicorn uses 8080 by default, but is it possible that another server process uses 8080 port? Why don't you use the netstat or lsof commands to check?Specifically, do the following with root privileges:

  • netstat

    # netstat-tlnp | grep':8080'

  • lsof

    # lsof-i TCP:8080

netstat

# netstat-tlnp | grep':8080'

lsof

# lsof-i TCP:8080


2022-09-30 15:49

The first quote from English version of the same question is that the unix domain socket cannot be in the shared directory of the Vagrant.Isn't that a shared directory by any chance?

Also, I don't know if it's unicorn, but Nodejs had a problem where the socks didn't automatically disappear when listening to the Unix domain socket.Of course, I can't listen if there's any trash left, so if there's a socket of the same name left, please try unlink it.


2022-09-30 15:49

The path in .sock described on the configuration file side in /etc/nginx/conf.d/ and the path specified in listen in unicorn.rb must be the same.

#'unicorn' part is proxy path
upstream unicorn {
    # Match the path here with 'unicorn.rb'
    server unix : /var/www/html/unicorn/tmp/sockets/unicorn.sock fail_timeout = 0;
}

server{
    location / {
        # match the name specified in upstream
        proxy_pass http://unicorn;
    }
}

Is the setting similar to the one shown in ?

The following article is for sinatra, but the explanation of unicorn and nginx may be helpful.

Sinatra Recipes-Deployment-Nginx Proxied To Unicorn


2022-09-30 15:49

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.