I'm working on a system whose primary startup system is runit.
Unfortunately, runit requires that whatever application it is running be running in the foreground like so:
#!/bin/bash
exec sshd -D
Seeing as nginx doesn't offer a way to run it in the foreground, how can I have runit still manage nginx and be able to stop, start, and restart it using runit's sv
commands?
Best Answer
You can use option
daemon off
:From nginx wiki:
When you use
runit
to controlnginx
, it becomes the parent process of thenginx
master process. But if you try to do an online upgrade, thenginx
master process will fork and execute the new binary.A new master process is created, but because old master process still exists (because it's controlled by
runit
), the parent of the new master process will be the init process, becauserunit
can not control new master master process as it didn't start it.