ruby-on-rails - Foreman无法启动Nginx,但我可以手动启动。为什么?

标签 ruby-on-rails ruby process nginx foreman

我目前正在运行 Foreman在暂存 (Ubuntu) 上,一旦我开始工作,就会切换到使用 upstart。

我的 Procfile.staging 看起来像这样:

nginx: sudo service nginx start
unicorn: bundle exec unicorn -c ./config/unicorn.rb
redis: bundle exec redis-server
sidekiq: bundle exec sidekiq -v -C ./config/sidekiq.yml

我可以使用以下方法成功启动 nginx:

$ sudo service nginx start

然而,当我运行 $ foreman start 时,当其他三个进程成功启动时,nginx 却没有:

11:15:46 nginx.1   | started with pid 15966
11:15:46 unicorn.1 | started with pid 15968
11:15:46 redis.1   | started with pid 15971
11:15:46 sidekiq.1 | started with pid 15974
11:15:46 nginx.1   | Starting nginx: nginx.
11:15:46 nginx.1   | exited with code 0
11:15:46 system    | sending SIGTERM to all processes
SIGTERM received
11:15:46 unicorn.1 | terminated by SIGTERM
11:15:46 redis.1   | terminated by SIGTERM
11:15:46 sidekiq.1 | terminated by SIGTERM

那么为什么当 Foreman 启动时 nginx 没有启动呢?

最佳答案

这是您的 Procfile 中的问题。

nginx 命令不能在foreman 中使用sudo,因为它会总是要求输入密码然后它会失败。这就是为什么您没有启动 nginx 并且日志为空的原因。

如果你真的需要在 procfile 中使用 sudo,你可以使用这样的东西:

sudo_app: echo "sudo_password" | sudo -S app_command
nginx: echo "sudo_password" | sudo -S service nginx start

我真的不推荐。另一种选择是调用 sudo foreman start

有关更多信息,请查看此 issue on github ,这正是您要解决的问题。

如果它适合你,请告诉我。

关于ruby-on-rails - Foreman无法启动Nginx,但我可以手动启动。为什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14645327/

相关文章:

mysql - 如何计算具有 Rails 关系的列总数

ruby-on-rails - ruby to_json :methods arguments

c# - 如何确定退出代码来自哪里?

linux - 调用fork后什么时候创建用户空间栈?

ruby-on-rails - Rails 3 的这一行有什么作用?

ruby-on-rails - Rails 4 AbstractController::Metal 渲染状态 != 200(即 401、404)

Ruby & 冒号快捷方式

ruby-on-rails - 使用rails中lib目录中的类函数

android - Android App Widgets 是运行在应用进程还是宿主进程?

javascript - 当我需要使用 browserify-rails 时,formsy-react npm 模块会破坏 Rails 应用程序