工头不与NGINX合作

Kyl*_*Fox 6 passenger nginx upstart foreman

我正在尝试使用Foreman(版本0.31.0)来管理我们的应用程序的进程,但我对nginx(nginx/1.0.10 + Phusion Passenger 3.0.11)没有太多运气.

这是我的Procfile中的相关行:

nginx: sudo /home/ubuntu/nginx/sbin/nginx
Run Code Online (Sandbox Code Playgroud)

当我启动应用程序时,Foreman报告nginx已启动,然后立即终止:

$ foreman start
21:18:28 nginx.1   | started with pid 27347
21:18:28 nginx.1   | process terminated
21:18:28 system    | sending SIGTERM to all processes
Run Code Online (Sandbox Code Playgroud)

但是,即使Foreman另有报告,nginx实际上仍在运行.


同样,如果我导出到Upstart:

rvmsudo foreman export upstart /etc/init -a my_app -u ubuntu
Run Code Online (Sandbox Code Playgroud)

并运行sudo start my_app,nginx正常启动.但sudo stop my_app 不会阻止nginx.它继续运行.

让nginx与Foreman合作是否有诀窍?

注意:我发现Foreman的这个问题,我想知道它是否相关.

Dav*_*lar 9

您需要通过在nginx.conf中添加以下内容来在前台模式下运行nginx

daemon off;
Run Code Online (Sandbox Code Playgroud)

您可以使用-c参数为nginx指定自定义nginx.conf

  • 您可以执行`/ usr/local/nginx/sbin/nginx -g"守护程序关闭;"`而不是修改nginx.conf但是`daemon off`用于开发.工头是否用于生产? (3认同)