NAME
Ubic::Service - interface and base class for any ubic service
VERSION
version 1.15
SYNOPSIS
print "Service: ", $service->name;
$service->start;
$service->stop;
$service->restart;
$status = $service->status;
DESCRIPTION
All ubic services must be subclasses of this package.
Action methods (like start
, stop
, reload
) and status
should return Ubic::Result::Class objects (usually constructed with result
method from Ubic::Result).
Or they can return plain strings, Ubic will care about blessing them into result objects.
See "SEE ALSO" for references to more specific (and useful) versions of services.
METHODS
- name()
- name($new_name)
-
Name of service.
Each service with the same parent should have an unique name.
In case of subservices, name should be the most lower-level name; use
full_name
method to get fully-qualified service name. - full_name
-
Fully qualified name of service.
Each service should have an unique full_name.
It is a concatenation of service's short
name
and service's <parent_name>.Service's parent is responsible for setting it (to concatenation of it's own name and service's name) immediately after service's construction.
In case of subservices, initial name should be the most lower-level name; it will be concatenated with names of it's parents by it's parents. (See Ubic::Multiservice's code for more details).
- parent_name()
- parent_name($new_parent_name)
-
Get/set name of service's parent.
Service's parent is responsible for calling it immediately after service's construction as
$service->parent_name($self->full_name)
. - start
-
Start service. Should throw exception on failure and string with operation result otherwise.
Starting already running service should do nothing and return "already running".
- stop
-
Stop service. Should throw exception on failure and string with operation result otherwise.
Stopping already stopped service should do nothing and return "not running".
Successful stop of a service must disable this service.
- status
-
Check real status of service.
It should check that service is running correctly and return "running" if it is so.
- reload
-
Reload service, if possible.
- port
-
Should return port number if service provides a server which uses TCP protocol.
- user
-
Should return user from which the service can be controlled and will be running. Default is
root
. - group
-
Should return 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 gid, other groups will be set as supplementary groups.
Default is list of all groups of user as returned by
user()
method. - check_period
-
Should return 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 :)
- custom_commands()
-
Can return list of service's custom commands, if such are exist.
- do_custom_command($command)
-
Should execute specified command, if it is supported.
SEE ALSO
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 - just give it any binary and it will make service from it.
AUTHOR
Vyacheslav Matjukhin <mmcleric@yandex-team.ru>
COPYRIGHT AND LICENSE
This software is copyright (c) 2010 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.