Soop.pm

You can download Soop.pm here.

NAME

Soop - Supervise any process, and make it behave like a daemon

SYNOPSIS

 use Soop;
 my $supervisor = Soop->new( %options_hash );
 $supervisor->begin();

DESCRIPTION

Soop is a process supervisor along the lines of djb's daemontools. It will fork a child, execute the given process, and restart it whenever it exits. Soop can also run user-defined tests at a preset interval to determine whether or not the child process should be stopped or restarted. Logging is done to STDERR or syslog, user's choice.

METHODS

EXAMPLE

The following example code will create an SSH tunnel to an SMTP server running on localhost, daemonize, sleep for 30 seconds, and then restart the tunnel when the second test is evaluated (and returns failure):
  my $supervisor = Soop->new(
    process => {
        cmd => '/usr/bin/ssh',
        args => [ '-N', '-L 2222:localhost:25', 'localhost' ]
    },

    verbose         => 1,
    daemonize       => 1,
    path            => '/bin',
    uid             => 1000,
    gid             => 1000,
    pid_file        => './sooptest.pid',

    use_syslog      => 1,
    syslog_facility => 'daemon',
    syslog_ident    => 'sooptest',

    snoozetime      => 30,
    
    tests           => [
        sub {
            my $self = shift;
            print "This is a successful test.\n";
            return 1;
        },
        sub {
            my $self = shift;
                        print "This test will always fail!\n";
            return 0;
        }
    ]
);
$supervisor->begin();

VERSION

This is verison 1.1 of Soop.pm

AUTHOR

Greg Boyington <greg@automagick.us>

License

Creative Commons License
All source code, tools and scripts on http://automagick.us is Copyright © 2007 - 2010 Greg Boyington, and licensed under a
Creative Commons Attribution-Share Alike 3.0 United States License, except where otherwise noted.