NAME

App::Sv - Event-based multi-process supervisor

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_retries => 5,
        restart_delay => 1,
        start_wait => 1,
        stop_wait => 2,
        umask => '027',
        user => 'www',
        group => 'www'
      },
    },
    global => {
      listen => '127.0.0.1:9999',
      umask => '077'
    },
);
$sv->run;

DESCRIPTION

This module implements an event-based multi-process supervisor.

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

You can send SIGTERM to the supervisor process to kill all children 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.

METHODS

new

my $sv = App::Sv->new({ run => {...}, global => {...}, log => {...} });

Creates a supervisor instance with a list of commands to monitor. It accepts an anonymous hash with the following options:

run

$sv->run;

Starts the supervisor, forks and executes all the services in child processes and monitors each one.

This method returns when the supervisor is stopped with either a SIGINT or a SIGTERM.

ENVIRONMENT

AUTHOR

Gelu Lupaş gvl@cpan.org

CONTRIBUTORS

SEE ALSO

App::SuperviseMe, ControlFreak, Supervisor

COPYRIGHT AND LICENSE

Copyright (c) 2011-2014 the App::Sv "AUTHOR" and "CONTRIBUTORS" as listed above.

This is free software, licensed under:

The Artistic License 2.0 (GPL Compatible)s