nginxdaemonrunit

Nginx and runit....what is best practice


I am rather confused about ensuring that nginx is always up. My understanding the init.d script justs start and stops nginx. Is this correct? Then in the docs its says to keep daemon = off;

Now, I would like to use runit and the below is my runit run script:

#!/bin/sh
exec /etc/init.d/nginx start

I notice that a new PID is always created.

So in sum: 1) I do NOT have this statement in the nginx file:

daemon = off;

2) I am using the above runit script but it always creates a new PID.

So...what is best practice to ensuring that nginx is always running.

I am using monit by the way but would runit to own hte daemon.

As a test, I did kill nginx using killall -9 nginx and I did a ps aux | grep nginx and noticed I got new pid's. So..do I still need runit?


Solution

  • Nginx has a master process that manages the worker processes. It keeps itself running. By making nginx run in the foreground and letting some other application manage is poorly reinventing the wheel.