Proc::Launcher::Supervisor - restart watched processes that have exited


Proc-Launcher documentation Contained in the Proc-Launcher distribution.

Index


Code Index:

NAME

Top

Proc::Launcher::Supervisor - restart watched processes that have exited

VERSION

Top

version 0.0.35

DESCRIPTION

Top

This is a tiny module that's designed for use with panctl and Proc::Launcher, where it is forked off and run as a separate process.

ATTRIBUTES

Top

monitor_delay

Number of seconds to sleep before attempting to restart any daemons that aren't running. Defaults to 15.

manager

A Proc::Launcher::Manager object, with daemons already registered. The supervisor will call the manager's start method at regular intervals. This will start any daemons that are not found running.

METHODS

Top

$obj->monitor()

This tiny class contains only this one method.

It will repeatedly sleep for a configured period of time (default 15 seconds), and then call start_all() on the manager object. This will result in restarting any processes that have stopped.

LICENCE AND COPYRIGHT

Top


Proc-Launcher documentation Contained in the Proc-Launcher distribution.

package Proc::Launcher::Supervisor;
use strict;
use warnings;

our $VERSION = '0.0.35'; # VERSION

use Mouse;

has 'monitor_delay' => ( is       => 'rw',
                         isa      => 'Int',
                         default  => 15,
                     );

has 'manager'       => ( is       => 'rw',
                         isa      => 'Proc::Launcher::Manager',
                         required => 1,
                     );

sub monitor {
    my ( $self ) = @_;

    sleep 5;

    while ( 1 ) {
        $self->manager->start();
        sleep $self->monitor_delay;
    }
}

no Mouse;

1;

__END__