【问题标题】:Can't start unicorn, master failed to start, check stderr log for details无法启动独角兽,master启动失败,查看stderr log了解详情
【发布时间】:2013-06-19 10:04:31
【问题描述】:

我不知道 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"

运行 nginx 成功。

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

【问题讨论】:

  • /var/www/demo/log/unicorn.stderr.log 中的 stderr 日志说明了什么?顺便说一句,您将 stdout 和 stderr 记录到同一个文件中。
  • 没有这样的文件或目录 - /path/to/.unicorn.sock (Errno::ENOENT)

标签: ruby-on-rails nginx production-environment unicorn


【解决方案1】:

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

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

然后,在你的 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;
}

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-10-09
    • 2016-08-01
    • 2012-06-01
    • 2023-03-23
    • 1970-01-01
    • 2023-03-09
    • 1970-01-01
    相关资源
    最近更新 更多