6

I'm trying to use Foreman (version 0.31.0) to manage our application's processes but I'm not having much luck with nginx (nginx/1.0.10 + Phusion Passenger 3.0.11).

Here's the relevant line from my Procfile:

nginx: sudo /home/ubuntu/nginx/sbin/nginx

When I start the app, Foreman reports that nginx is started and then immediately terminated:

$ 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

However, nginx is actually running, even though Foreman reports otherwise.


Similarly, if I export to Upstart:

rvmsudo foreman export upstart /etc/init -a my_app -u ubuntu

and run sudo start my_app, nginx starts properly. But sudo stop my_app does not stop nginx. It continues running.

Is there a trick to getting nginx to work with Foreman?

Note: I found this issue with Foreman and I'm wondering if it's related.

Kyle Fox
  • 3,133
  • 4
  • 23
  • 26

1 Answers1

9

You'll want to run nginx in foreground mode by adding the following to your nginx.conf

daemon off;

You can specify a custom nginx.conf to nginx with the -c argument

pje
  • 21,801
  • 10
  • 54
  • 70
David Dollar
  • 2,409
  • 17
  • 18
  • Yep, works perfectly now. Thanks! I assume this is one of the allowable exceptions to the _"don't use `daemon off` in production"_ rule mentioned in the nginx docs for [daemon](http://wiki.nginx.org/CoreModule#daemon). – Kyle Fox Jan 04 '12 at 22:44
  • 3
    You can do `/usr/local/nginx/sbin/nginx -g "daemon off;"` instead of modifying the nginx.conf but `daemon off` is for development. Is foreman used in production? – PhilT May 23 '12 at 07:00