- SEE ALSO
- COPYRIGHT AND LICENSE
XAS::Lib::Service - A class to interact with Services
use XAS::Lib::Service; my $service = XAS::Lib::Service->new( -alias => 'service', -poll_interval => 2, -shutdown_interval => 25 ); $service->run();
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.
This method is used to initialize the service. This module inherits from XAS::Lib::POE::Session. It takes the following parameters:
The name of this POE session. Defaults to 'service';
This is the interval were the SCM sends SERVICE_RUNNING message. The default is every 2 seconds.
This is the interval to pause the system shutdown so that the service can cleanup after itself. The default is 25 seconds.
This allows your process to register whatever modules you want events sent too.
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.
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:
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.
This is fired when your process is shutting down.
This is fired when your process needs to "pause".
This is fired when your process needs to "resume".
This is fired at every poll_interval.
Kevin L. Esteb, <email@example.com>
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.