I use daemon tools with gearman
I was thinking whether I should configure daemon tools for Nginx
or does it handle its shutdown (in case of memory issue, etc..) automatically?

- 160
- 2
- 9
-
Which OS/distribution? – dawud Apr 05 '14 at 21:34
-
Ubuntu 12.04 LTS – Jad Joubran Apr 05 '14 at 22:21
-
`service nginx start/stop` doesn't work for you? – dawud Apr 06 '14 at 08:29
-
it does.. Nginx works fine.. I was just asking if I need to use daemontools to "monitor" Nginx.. is it necessary? – Jad Joubran Apr 06 '14 at 10:48
-
If you're asking if you _can_ use `supervise` with `nginx`, the answer is yes. – dawud Apr 06 '14 at 14:11
-
1You could, but there's little point. nginx supervises itself. – Michael Hampton Apr 06 '14 at 20:00
-
@MichaelHampton Thank you! You answered my question precisely – Jad Joubran Apr 07 '14 at 10:47
1 Answers
As someone who fell in love with daemontools thirteen years ago, I too try to supervise all the things. nginx is a bit feisty though, you have to use at least daemon off;
in your config to run it in the foreground, and master_process off;
if you really don't want it spawning any children. Just exec
it then from your run program and it will behave like you expect.
I was cutting against the grain, however. I've come to accept that nginx has supervision built in. You'll notice that when you run it you get something like this:
$ psg nginx
root 1361 1 0 Mar31 ? 00:00:00 nginx: master process /usr/sbin/nginx
www-data 1362 1361 0 Mar31 ? 00:18:10 nginx: worker process
www-data 1363 1361 0 Mar31 ? 00:18:44 nginx: worker process
$ pstree -p 1361
nginx(1361)─┬─nginx(1362)
└─nginx(1363)
The master process is essentially supervise
. It's super lightweight and is solely responsible for making sure workers are running properly. I've never once had it crash on me, even in some fairly busy environments. So now I just let init
stop/start it and worry about services I do need to supervise.
There are other considerations. Check out what the official documentation has to say about it: http://nginx.org/en/docs/faq/daemon_master_process_off.html

- 146
- 3
-
Doc TL;DR - `master_process off;` / `daemon off;` break zero-downtime upgrades and are mostly for Nginx developers. – Sep 12 '15 at 03:36