Ruby-on-rails 无法启动独角兽,master启动失败,查看stderr日志了解详情

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/17249385/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:12:49  来源:igfitidea点击:

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

ruby-on-railsnginxproduction-environmentunicorn

提问by Pravin Mishra

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

我不知道 unicorn.rb 文件有什么问题。我的 unicorn.rb 配置是

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.

运行nginx成功。

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

回答by Frank C. Schuetz

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:

套接字是 nginx 和 unicorn 用作它们之间所有通信的通道的“文件”。你在哪里定义的?在我们的独角兽配置中,我们通常有这样一行:

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

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

然后,在你的 nginx.conf 中,你需要告诉 nginx 这个套接字,例如:

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.

在这个配置文件中,第一部分定义了 nginx 如何到达 unicorn。第二个实际上将请求路由到抽象位置“@unicorns”,而后者又在最后一节中定义。这样,如果您有更复杂的 nginx 路由,您可以重用 @unicorns 速记。