Ubuntu – Monit — Daemonize non-daemon process

monitUbuntuunix

I have a ruby process that don't run as a daemon (it runs in the foreground), but can generate a pid file. My question is does Monit always expects to monitor background/daemonized processes?

I used Bluepill in the past, and that was the default behaviour:

Note that since we specified a PID file and start command, bluepill assumes the process will daemonize itself. If we wanted bluepill to daemonize it for us, we can do (note we still need to specify a PID file): process.daemonize = true

Is there something similar for monit? AFAIK, as long as the process (daemon or not) can create a PID file, Monit will detect if it daemonize itself and won't daemonize it and vice versa…

Thank you

Best Answer

It will work fine for monit.. You can have it check the pid file of the process and basically what monit is doing is doing a

ps aux | grep pid#

If it's there it think's it's up and running. If you don't have a pid file you can check a process also via something like

check process myprocessname
    matching "myprocessname"

That pretty much does a

ps aux | grep myprocessname