Start the service. Should throw an exception on failure and a result object or a string with operation result otherwise.
Starting an already running service should do nothing and return already running.
Stop the service. Should throw an exception on failure and a result object or a string with operation result otherwise.
Stopping an already stopped service should do nothing and return not running.
Check the status of the service.
It should check that service is running correctly and return running if it is so.
Reload the service if possible.
Throw an exception if reloading is not implemented (default implementation already does so).
All metadata methods are read-only. All of them provide the sane defaults.
<B>B>port()<B>B> Get the port number if a service listens for a TCP port.
Default is undef.
<B>B>user()<B>B> Get the user from which the service can be controlled and will be running.
Defaults to default_user from Ubic::Settings (i.e., root for a system-wide installation, or to the installation owner for a local installation).
<B>B>group()<B>B> Get the list of groups from which the service can be controlled and will be running.
First group from the list will be used as real and effective group id, and other groups will be set as supplementary groups.
Default is an empty list, which will later be interpreted as default group of the user returned by user() method.
<B>B>check_period()<B>B> Period of checking a service by watchdog in seconds. <B>B>check_timeout()<B>B> Timeout after which the watchdog will give up on checking the service and will kill itself.
This parameter exists as a precaution against incorrectly implemented status() or start() methods. If a status() method hangs, without this timeout, watchdog would stay in memory forever and never get a chance to restart a service.
Default value is 60 seconds. It should not be changed unless you have a very good reason to do so (i.e., your service is so horribly slow that it cant start in 1 minute).
Services can define custom commands which dont fit into the usual start/stop/restart/status set.
<B>B>custom_commands()<B>B> Should return the list of services custom commands, if there are any. <B>do_custom_command($command)B> Should execute specified command, if it is supported. Throw an exception otherwise.
These methods should not be overridden by specific service classes. They are usually used by the code which loads service (i.e. some kind of Ubic::Multiservice) to associate service with its name.
These methods are just the simple interdependent r/w accessors.
<B>B>name()<B>B> <B>name($new_name)B> Get or set a name of the service.
Each service with the same parent should have an unique name.
In case of subservices, this method should return the most lower-level name.
Service implementation classes shouldnt override this or other *_name methods; its usually a services loader job to set them correctly.
<B>B>full_name()<B>B> Get a fully qualified name of the service.
Each service must have a unique full_name.
Full name is a concatenation of services short name and services <parent_name>.
<B>B>parent_name()<B>B> <B>parent_name($new_parent_name)B> Get or set a name of the services parent.
Services loader (i.e. some kind of Ubic::Multiservice) is responsible for calling this method immediately after a service is constructed, like this: $service->parent_name($self->full_name) (check out Ubic::Multiservice sources for more).
<B>B>auto_start()<B>B> A boolean value that determines the state of a service if it has never been explicitly enabled or disabled yet. Service is considered initially enabled when auto_start is true.
Default is false, so initial service status is off, and you have to run ubic start service_name to start it.
Current API for custom commands is inconvenient and doesnt support parameterized commands. It needs some refactoring.
Requiring every service to inherit from this class can be seen as undesirable by some programmers, especially by those who prefer to use Moose and roles. If you know how to make this API more role-friendly without too much of converting pains, please contact us at email@example.com or at irc://irc.perl.org#ubic.
Ubic::Service::Skeleton - implement simple start/stop/status methods, and ubic will care about everything else.
Ubic::Service::Common - just like Skeleton, but all code can be passed to constructor as sub references.
Ubic::Service::SimpleDaemon - give it any binary and it will make a service from it.
Vyacheslav Matyukhin <firstname.lastname@example.org>
This software is copyright (c) 2015 by Yandex LLC.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
|perl v5.20.3||UBIC::SERVICE (3)||2015-01-27|