NAME
XAS::Lib::Process - A class for managing processes within the XAS environment
SYNOPSIS
use XAS::Lib::Process;
my $process = XAS::Lib::Process->new(
-command => 'perl test.pl'
);
$process->run();
DESCRIPTION
This class manages a sub process in a platform independent way. Mixins are loaded to handle the differences between Unix/Linux and Windows. This module inherits from XAS::Lib::POE::Service. Please refer to that module for additional help.
METHODS
new
This method initialized the module and takes the following parameters:
- -command
-
The command to run.
- -auto_start
-
This indicates wither to autostart the process. The default is true.
- -auto_restart
-
This indicates wither to restart the process if it exits. The default is true.
- -directory
-
The optional directory to start the process in. Defaults to the current directory of the parent process.
- -environment
-
Optional, addtitional environment variables to provide to the process. The default is none.
- -exit_codes
-
Optional exit codes to check for the process. They default to '0,1'. If the exit code matches, then the process is auto restarted. This should be a comma delimited list of values.
- -exit_retries
-
The optional number of retries for restarting the process. The default is 5.
- -group
-
The group to run the process under. Defaults to 'nobody'. This group may not be defined on your system. This option is not implemented on Windows.
- -priority
-
The optional priority to run the process at. Defaults to 0. This option is not implemented on Windows.
- -umask
-
The optional protection mask for the process. Defaults to '0022'. This option is not implemented on Windows.
- -user
-
The optional user to run the process under. Defaults to 'nobody'. This user may not be defined on your system. This option is not implemented on Windows.
- -redirect
-
This option is used to indicate wither to redirect stdout and stderr from the child process to the parent and stdin from the parent to the child process. The redirection combines stderr with stdout. Redirection is implemented using sockets. This may cause buffering problems with the child process.
The default is no.
- -input_driver
-
The optional input driver to use. Defaults to POE::Driver::SysRW.
- -output_driver
-
The optional output driver to use. Defaults to POE::Driver::SysRW.
- -input_filter
-
The optional filter to use for input. Defaults to POE::Filter::Line.
- -output_filter
-
The optional output filter to use. Defaults to POE::Filter::Line.
PUBLIC EVENTS
The following public events have been defined. The following arguments are provided by POE as offsets into the argument array.
put_input(OBJECT, ARG0)
This event will write a buffer to stdin.
get_output(OBJECT, ARG0, ARG1)
This event will read a buffer for stdout/stderr.
flush_event(OBJECT, ARG0)
This event is fired when a flush event happens on stdin.
error_event(OBJECT, ARG0..ARG4)
This event is fired whenever an error occurs.
- ARG0 - the operation that was being performed i.e. read/write
- ARG1 - the errno that occurred
- ARG2 - the errstr for that errno
- ARG3 - the wheel ID
- ARG4 - the type i.e. INPUT/OUTPUT
close_event(OBJECT)
This event is fired when a "close" happens on the sockets.
SEE ALSO
AUTHOR
Kevin L. Esteb, <kevin@kesteb.us>
COPYRIGHT AND LICENSE
Copyright (C) 2015 Kevin L. Esteb
This is free software; you can redistribute it and/or modify it under the terms of the Artistic License 2.0. For details, see the full text of the license at http://www.perlfoundation.org/artistic_license_2_0.