Topic: missing unicorn.sock

Hi all,

I'm a bit new in Rails and I'm trying to deploy a RoR application using capistrano/nginx/unicorn.
For this I dupplicated an existing configuration.

Nginx seems to work perfectly but strangly, I'm not able to start unicorn with the following command :

 unicorn_rails -c config/unicorn.rb -E production -D 

I get : master failed to start, check stderr log for details
And looking to the logs, it seems that unicorn.sock is missing
->  No such file or directory - "......./shared/sockets/unicorn.sock" (Errno::ENOENT)

Indeed, I can't find unicorn.sock anywhere in the server...

Do you have any clue about the issue, ar do you don't how I could track the problem ?

Thanks a lot for your help.

Last edited by skess75 (2013-04-08 15:49:48)

Re: missing unicorn.sock

Does the shared/sockets folder exists?  Unicorn should create the socket file on its own if the shared/sockets directory exists and is writeable by the user that the unicorn processes is running as.

Re: missing unicorn.sock

The "shared" folder exists but not the "sockets" one...
Any guess what's going on ?

Re: missing unicorn.sock

Create the sockets folder and it should stop giving you the error.

Re: missing unicorn.sock

I just tried it and it worked, thanks a lot !!

But know, I'm getting stuck with an other issue...
I think I'm not able to connect nginx and unicorn. I checked and rechecked the files, and it all seems ok to me (knowing that I'm beginner).

The nginx log file gives me lots of this kind of errors :

 2013/04/14 00:31:42 [error] 14469#0: *1 connect() to unix:/home/user/www/my_app/shared/sockets/unicorn.sock 
failed (111: Connection refused) while connecting to upstream, client: XX.XXX.XX.XX, server: myapp.com, 
request: "GET / HTTP/1.1", upstream: "http://unix:/home/user/www/myapp/shared/sockets/unicorn.sock:/", 
host: "www.myapp.com"

Is there a way to monitor where the problem is ?
I could send over the requested files if needed..

Thanks again for your help :-)

Last edited by skess75 (2013-04-13 18:49:32)

Re: missing unicorn.sock

Can you post your nginx config?

Re: missing unicorn.sock

Of course (app name is "sahitoo") :

user www-data;
worker_processes 4;
pid /var/run/nginx.pid;

events {
  worker_connections 768;
  multi_accept on;
}

http {
  ##
  # Basic Settings
  ##

  sendfile on;
  tcp_nopush on;
  tcp_nodelay on;
  keepalive_timeout 65;
  types_hash_max_size 2048;
  # server_tokens off;

  # server_names_hash_bucket_size 64;
  # server_name_in_redirect off;

  include /etc/nginx/mime.types;
  default_type application/octet-stream;

  ##
  # Logging Settings
  ##

  access_log /var/log/nginx/access.log;
  error_log /var/log/nginx/error.log;

  ##
  # Gzip Settings
  ##

  gzip on;
  gzip_disable "msie6";

  # gzip_vary on;
  # gzip_proxied any;
  # gzip_comp_level 6;
  # gzip_buffers 16 8k;
  gzip_http_version 1.1;
  gzip_types text/plain text/css application/json application/x-javascript text/xml application/xml application/xml+rss text/javascript;

  ##
  # Virtual Host Configs
  ##

  include /etc/nginx/conf.d/*.conf;
  include /etc/nginx/sites-enabled/*;

  upstream sahitoo {
    server unix:/home/kar/www/sahitoo/shared/sockets/unicorn.sock;
  }
}

Thanks

Re: missing unicorn.sock

With
/etc/nginx/sites-enabled/sahitoo file :

server {
  listen 80;
  server_name mysite.com;

  access_log /var/log/nginx/sahitoo.access.log;
  error_log /var/log/nginx/sahitoo.error.log;

  root /www/sahitoo/public;

  # direct to maintenance if this file exists
  if (-f $document_root/system/maintenance.html) {
    rewrite  ^(.*)$  /system/maintenance.html last;
    break;
  }

  location / {
    proxy_redirect          http://sahitoo/               /;
    proxy_set_header        Host                                                            $host;
    proxy_set_header        X-Real-IP                                                     $remote_addr;
    proxy_set_header  X-Forwarded-For                                               $proxy_add_x_forwarded_for;

    # If the file exists as a static file serve it directly
    if (-f $request_filename) {
      break;
    }

    if (!-f $request_filename) {
      proxy_pass http://sahitoo;
      break;
    }
  }

  error_page   500 502 503 504  /500.html;
  location = /500.html {
    root   /home/kar/www/sahitoo/public;
  }
}

Last edited by skess75 (2013-04-15 17:56:31)