Easy, but production-ready process monitor in Linux/Unix [closed]
Solution 1:
You're looking for the program daemontools. (If this is what you meant by the "Supervisor" monitor, then feel free to ignore the rest of my answer.)
daemontools is a collection of tools for managing UNIX services.
supervise monitors a service. It starts the service and restarts the service if it dies. Setting up a new service is easy: all supervise needs is a directory with a run script that runs the service.
multilog saves error messages to one or more logs. It optionally timestamps each line and, for each log, includes or excludes lines matching specified patterns. It automatically rotates logs to limit the amount of disk space used. If the disk fills up, it pauses and tries again, without losing any data.
It's simple, flexible, and very powerful. The basic idea is that for each service you want to run, daemontools launches a child process (called supervise
) that then launches your service. supervise
configures the service's environment variables and uid/gid, and then keeps the service's standard in and standard out open so it can send signals. The service does not need to daemonize itself, and you don't have to manage pid files. The main service doesn't require root to run, and you can put the directories of monitored services anywhere.
Solution 2:
The simple answer is you already have one - Every Unix system does - init and /etc/inittab.
The job of init is to spawn the processes listed in inittab, monitor them and restart them if they exit.