Can't start unicorn, master failed to start, check stderr log for details

Pravin Mishra picture Pravin Mishra · Jun 22, 2013 · Viewed 30.7k times · Source

I dont know what’s wrong with the unicorn.rb file. my unicorn.rb config is

APP_PATH = "/var/www/demo"
working_directory APP_PATH

stderr_path APP_PATH + "/log/unicorn.stderr.log"
stdout_path APP_PATH + "/log/unicorn.stderr.log"

pid APP_PATH + "/tmp/pid/unicorn.pid"

running nginx successful.

sudo servier nginx start
sudo unicorn -c /var/www/demo/config/unicorn.rb -D

Answer

Frank C. Schuetz picture Frank C. Schuetz · Jun 23, 2013

The socket is the "file" that nginx and unicorn use as a channel for all communication between them. Where have you defined it? In our unicorn configs, we usually have a line like this:

listen APP_PATH + "/tmp/pid/.unicorn.sock

Then, in your nginx.conf, you need to tell nginx about this socket, e.g.:

upstream unicorn {
  server unix:/var/www/demo/tmp/pid/.unicorn.sock fail_timeout=0;
}

location / {
  root /var/www/demo/current/public ;
  try_files $uri @unicorns;
}

location @unicorns {
  proxy_pass http://unicorn;
}

In this config file, the first section defines how nginx can reach unicorn. The second one actually routes requests to an abstract location "@unicorns" which, in turn, is defined in the last section. This way you can reuse the @unicorns shorthand if your have more complex nginx routing going on.