PrePAN

Sign in to PrePAN

App::Sv Simple process supervisor

Author
ggl@github
Date
URL
https://github.com/ggl/App-Sv
Status
In Review
Good

Synopsis

my $sv = App::Sv->new(
	run => {
	  x => 'plackup -p 3010 ./sites/x/app.psgi',
	  y => {
		cmd => 'plackup -p 3011 ./sites/y/app.psgi'
		start_delay => 1,
		start_retries => 5,
		umask => 0027,
		user => 'www',
		group => 'www'
	  },
	},
	global => {
	  listen => '127.0.0.1:9999',
	  daemon => 0,
	  umask => 0077
	},
);
$sv->run;

Description

This module implements a multi-process supervisor.

It takes a list of commands to execute and starts each one, and then monitors their execution. If one of the programs dies, the supervisor will restart it after start_delay seconds. If a program respawns during start_delay for start_retries times, the supervisor gives up and stops it indefinitely.

You can send SIGTERM to the supervisor process to kill all childs and exit.

You can also send SIGINT (Ctrl-C on your terminal) to restart the processes. If a second SIGINT is received and no child process is currently running, the supervisor will exit. This allows you to tap Ctrl-C twice in quick succession in a terminal window to terminate the supervisor and all child processes.

Comments

Isn’t this Server::Starter?
Server::Starter does not come with a socket for controlling supervised services, the ability to log state changes, nor is it event-based. This is more similar to ControlFreak and Supervisor which are written using event loops.
Add links to those in the SEE ALSO section of App::Sv

Please sign up to post a review.