Proclaunch is a super simple pure-perl user space process manager. It starts your processes and keeps them running. It's comparable to runit, except it manages processes that know how to daemonize themselves. It's also only a few hundred lines of simple perl with minimal dependencies.
$ git clone git://github.com/peterkeen/proclaunch.git $ cd proclaunch $ perl Build.PL $ ./Build install
$ proclaunch [options] [state directory] [profile directory]
When executed, proclaunch will daemonize itself and write it's pid file to
The profile directory should contain a series of directories, each of which describes a process to be managed via a set of specially named files:
pid_filecontains the path to the file where run will place it's pid
runis an executable script that will daemonize itself and write it's pid to the path in pid_file
restartis an optional empty file who's presence tells proclaunch to restart
runif it dies.
stop_signalis an optional file that should contain a signal name that proclaunch will use to terminate the process. Default is SIGTERM.
reloadis an optional file who's presence indicates that proclaunch should send the contained signal and assume that the process will either continue running or manage it's own lifecycle. An empty file will use the default SIGHUP.
useris an optional file containing the user name that should execute
run. Only effective if proclaunch has been run as root.
Options can include:
--foreground -Frun in the foreground. Do not daemonize.
--debug -Dinclude DEBUG output in proclaunch's log
--log-level=[LOG LEVEL]instead of just debug, you can specify FATAL, WARN, INFO, or DEBUG as the maximum level of logging information you want. Default is INFO.
Initially, proclaunch will launch all profiles contained in the profile directory. When a profile exits and the
restart file exists, the profile will be restarted. Additionally, proclaunch will scan every second to see if either an individual profile directory has changed, been added, or disappeared. Added profiles will be started, removed profiles will be stopped with SIGTERM or another signal as indicated in the
restart file, and changed profiles will be restarted or reloaded. Changes are determined by comparing file stats of the above set of files, not the directory as a whole.
Proclaunch daemonizes itself by default, so the easiest thing to do is add a line to crontab:
* * * * * /usr/local/bin/proclaunch /var/run/proclaunch /path/to/your/profiles/directory
Proclaunch is idempotent, meaning if it's already running it'll silently exit. This cron entry ensures that it will be restarted if it falls over for any reason.
To stop proclaunch without stopping profiles, send it SIGINT or SIGTERM. If you want to stop all of the profiles as well, send it SIGHUP. It will wait around for all the profiles to die, so if you have a misbehaving profile you can send it SIGHUP again and proclaunch will die immediately. Your misbehaving profile will continue to misbehave.
If you have bug reports, please use the Github issue tracker. If you have something to contribute, fork proclaunch and send me a pull request :)