- FUTURE DIRECTIONS
- SEE ALSO
- COPYRIGHT AND LICENSE
Ubic::Service - interface and base class for any ubic service
print "Service: ", $service->name; $service->start; $service->stop; $service->restart; $status = $service->status;
Ubic::Service is the abstract base class for all ubic service classes.
It provides common API for implementing service start/stop operations, custom commands and tuning some metadata properties (
Start service. Should throw exception on failure and string with operation result otherwise.
Starting already running service should do nothing and return
Stop service. Should throw exception on failure and string with operation result otherwise.
Stopping already stopped service should do nothing and return
Successful stop of a service must disable this service.
Check real status of service.
It should check that service is running correctly and return
runningif it is so.
Reload service, if possible.
All metadata methods are read-only. All of them provide sane defaults.
Get port number if service provides a server which uses TCP protocol.
Should return user from which the service can be controlled and will be running.
default_userfrom Ubic::Settings (i.e.,
rootfor system-wide installations, or to the installation owner for local installations).
Get list of groups from which the service can be controlled and will be running.
First group from 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
Period of checking a service by watchdog in seconds.
Default is 60 seconds and it is unused by ubic-watchdog currently, so don't bother to override it by now :)
Timeout after which watchdog will give up on checking a service and kill itself.
This parameter exists as a precaution against incorrectly implemented
status()method hangs, without this timeout, watchdog would stay in memory forever and never get a chance to restart a service.
This parameter is *not* a timeout for querying your service by HTTP or whatever your status check is. Service-specific timeouts should be configured by other means.
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 can't start in 1 minute).
Services can define custom commands which don't fit into usual
Can return list of service's custom commands, if such are exist.
Should execute specified command, if it is supported.
These methods usually should not be overriden by service classes. They are usually used by code which loads service (i.e. some Ubic::Multiservice) to associate service with its name.
Name of 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 shouldn't override this or other
*_namemethods; it's usually a service's loader job to set them correctly.
Fully qualified name of service.
Each service must have a unique full_name.
Full name is a concatenation of service's short
nameand service's <parent_name>.
Get/set name of service's parent.
Service's loader (i.e. some kind of Ubic::Multiservice) is responsible for calling this method immediately after service's construction as
Current API for custom commands is inconvenient and don't 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 service from it.
Vyacheslav Matyukhin <firstname.lastname@example.org>
This software is copyright (c) 2012 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.