NAME

XAS::Supervisor::Process - Defines a managed process for the Supervisor environment

SYNOPSIS

A managed process is defined and started as follows:

my $process = XAS::Supervisor::Process->new(
   -alias           => 'sleeper',
   -command         => 'sleeper.sh',
   -umask           => '0022',
   -user            => 'kesteb',
   -group           => 'users',
   -directory       => '/',
   -priority        => 0,
   -start_wait_secs => 10,
   -start_retries   => 5,
   -stop_signal     => 'TERM',
   -stop_wait_secs  => 10,
   -stop_retries    => 5,
   -reload_signal   => 'HUP',
   -auto_start      => TRUE,
   -auto_restart    => TRUE,
   -supervisor      => 'controller',
   -exit_codes      =>  '0,1',
   -environment     => 'item=value;;item2=value2'
);

$process->startme($ctx);

DESCRIPTION

A managed process is an object that knows how to start/stop/reload and return the status of that process. How the object knows what to do, is defined by the parameters that are set when the object is created. Those parameters are as follows.

PARAMETERS

-alias

The name the process is know by. A string value.

-command

The command to run within the process. A string value.

-user

The user context the run the process under. No effort is made to check if the user actually exists. A string value.

-group

The group context to run the process under. No effort is made to check if the group actually exists. A string value.

-umask

The umask for this process. A string value.

-directory

The directory to set default too when running the process. No effort is made to make sure the directory is valid. A string value.

-priority

The priority to run the process at. An integer value.

-start_retries

The number of retires when trying to start the process. An integer value.

-start_wait_secs

The number of seconds to wait between attempts to start the process. An integer value.

-stop_signal

The signal to send when trying to stop the process. A string value. It should be in a format that Perl understands.

-stop_retries

How many times to try and stop the process before issuing a KILL signal. An integer value.

-stop_wait_secs

The number of seconds to wait between attempts to stop the process. A intger value.

-reload_signal

The signal to use to attempt a "reload" on the process. A string value. It should in a format that Perl understands.

-auto_start

Wither the process should be auto started by a supervisor. A boolean value.

-auto_restart

Wither to attempt to restart the process should it unexpectedly exit. A boolean value.

-supervisor

The session name of a controlling supervisor. A string value.

-exit_codes

The expected exit codes from the process. If a returned exit code does not match this list, the process will not be restarted. This should be a comma delimited list of integers.

-environment

The environment variables for the process. This is a formated string. The format should be a double semi-colon delimited string of name/value pairs.

METHODS

In the following methods the $ctx parameter is used to hold context. It should not be directly manipulated.

startme($ctx)

This method will start the process running. Will return "start" if successful.

stopme($ctx)

This method will stop the process. Will return "stop" if successful.

statme($ctx)

This method will perform a "stat" on the process. It will return either "alive" or "dead".

reloadme($ctx)

This method will send a signal to the process to "reload".

killme($ctx)

This method will send a KILL signal to the process.

SEE ALSO

XAS

AUTHOR

Kevin L. Esteb, <kevin@kesteb.us>

COPYRIGHT AND LICENSE

Copyright (C) 2013 by Kevin L. Esteb

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself, either Perl version 5.8.5 or, at your option, any later version of Perl 5 you may have available.