NAME

XAS::Lib::Service - A class to interact with Services

SYNOPSIS

 use XAS::Lib::Service;

 my $service = XAS::Lib::Service->new(
    -alias             => 'service',
    -poll_interval     => 2,
    -shutdown_interval => 25
 );

 $service->run();

DESCRIPTION

This module provides a generic interface to "Services". A Service is a managed background process. It responds to external events. On Windows this would be responding to commands from the SCM. On Unix this would be responding to a special set of signals. This module provides an event loop that can interact those external events. The module XAS::Lib::POE::Service can interact with this event loop.

METHODS

new()

This method is used to initialize the service. This module inherits from XAS::Lib::POE::Session. It takes the following parameters:

-alias

The name of this POE session. Defaults to 'service';

-poll_interval

This is the interval were the SCM sends SERVICE_RUNNING message. The default is every 2 seconds.

-shutdown_interval

This is the interval to pause the system shutdown so that the service can cleanup after itself. The default is 25 seconds.

register($session)

This allows your process to register whatever modules you want events sent too.

$session

This can be an array reference or a text string. The text string may be delimited with commas. This will be the POE alias for each session.

EVENTS

When an external event happens this module will trap it and generate a POE event. These events follow closely the model defined by the Windows Service Control Manager interface. The event is then sent to all interested modules. The following POE events have been defined:

session_startup

This is fired when your process starts up and is used to initialize what ever processing you are going to do. On a network server, this may be opening a port to listen on.

session_shutdown

This is fired when your process is shutting down.

session_pause

This is fired when your process needs to "pause".

session_resume

This is fired when your process needs to "resume".

session_idle

This is fired at every poll_interval.

SEE ALSO

XAS::Lib::Service::Unix
XAS::Lib::Service::Win32
XAS

AUTHOR

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

COPYRIGHT AND LICENSE

Copyright (c) 2012-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.