Ubic - flexible perl-based service manager
version 1.36
Ubic->start("my-service"); Ubic->stop("my-service"); $status = Ubic->status("my-service");
This module is a singleton OOP class.
All of its methods can be invoked as class methods or object methods.
Ubic is a flexible perl-based service manager.
This module is a perl frontend to ubic services.
Further directions:
if you are looking for a general introduction to Ubic, see Ubic::Manual::Intro;
if you want to use ubic from command line, see ubic;
if you want to manage ubic services from perl scripts, read this POD;
if you want to write your own service, see Ubic::Service and other Ubic::Service::* modules.
Ubic::Service::*
All methods in this package can be invoked as class methods, but sometimes you may need to override some status dirs. In this case you should construct your own Ubic instance.
Ubic
Note that you can't create several instances in one process and have them work independently. So, this constructor is actually just a weird way to override service_dir and data_dir.
Constructor options (all of them are optional):
Name of dir with service descriptions (which will be used to construct root Ubic::Multiservice::Dir object).
Ubic::Multiservice::Dir
Dir into which ubic stores all of its data (locks, status files, tmp files).
See LSB documentation for init-script method specifications.
Following functions are trying to conform, except that all dashes in method names are replaced with underscores.
Unlike Ubic::Service methods, these methods are guaranteed to return blessed versions of result, i.e. Ubic::Result::Class objects.
Ubic::Service
Ubic::Result::Class
Start service.
Stop service.
Restart service; start it if it's not running.
Restart service if it is enabled.
Reloads service if reloading is implemented; throw exception otherwise.
Reloads service if reloading is implemented, otherwise restarts it.
Does nothing if service is disabled.
Get service status.
Enable service.
Enabled service means that service *should* be running. It will be checked by status and marked as broken if it's enabled but not running.
Returns true value if service is enabled, false otherwise.
Disable service.
Disabled service means that service is ignored by ubic. It's state will no longer be checked by watchdog, and pings will answer that service is not running, even if it's not true.
Get cached status of enabled service.
Unlike other methods, it can be invoked by any user.
Execute custom command $command for given service.
$command
Get service object by name.
Check whether service $name exists.
$name
Get list of all services.
Get list of names of all services.
Get root service.
Root service doesn't have a name and returns all top-level services with services() method. You can use it to traverse the whole service tree.
services()
Return list of autocompletion variants for given service prefix.
Write new status into service's status file.
Get data dir.
Set data dir, creating it if necessary.
Data dir is a directory with service statuses and locks. (See Ubic::Settings for more details on how it's calculated).
Ubic::Settings
This setting will be propagated into subprocesses using environment, so following code works:
Ubic->set_data_dir('tfiles/ubic'); Ubic->set_service_dir('etc/ubic/service'); system('ubic start some_service'); system('ubic stop some_service');
Deprecated. This method got renamed to set_data_dir().
set_data_dir()
Set default user for all services.
This is a simple proxy for Ubic::Settings->default_user($user).
Ubic::Settings->default_user($user)
Get ubic services dir.
Set ubic services dir.
You shouldn't call these from code which doesn't belong to core Ubic distribution
These methods can be changed or removed without further notice.
Get status file name by service's name.
Get status persistent object by service's name.
It's a bad idea to call this from any other class than Ubic, but if you'll ever want to do this, at least don't forget to create Ubic::AccessGuard first.
Ubic::AccessGuard
Get readonly, nonlocked status persistent object by service's name.
Get access guard (Ubic::AccessGuard object) for given service.
Acquire lock object for given service.
You can lock one object twice from the same process, but not from different processes.
Run any code and wrap result into Ubic::Result::Class object.
Run $cmd method from service $name and wrap any result or exception into Ubic::Result::Class object.
$cmd
Run $callback inside fork and return its return value.
$callback
Interaction happens through temporary file in $ubic-{tmp_dir}> dir.
$ubic-
Andrei Mishchenko <druxa@yandex-team.ru>
Yury Zavarin <yury.zavarin@gmail.com>
Dmitry Yashin
Christian Walde <walde.christian@googlemail.com>
Ivan Bessarabov <ivan@bessarabov.ru>
Most Ubic-related links are collected on github wiki: http://github.com/berekuk/Ubic/wiki.
Our mailing list is ubic-perl@googlegroups.com. Send an empty message to ubic-perl+subscribe@googlegroups.com to subscribe.
These is also an IRC channel: irc://irc.perl.org#ubic.
Vyacheslav Matyukhin <mmcleric@yandex-team.ru>
This software is copyright (c) 2011 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.
To install Ubic, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Ubic
CPAN shell
perl -MCPAN -e shell install Ubic
For more information on module installation, please visit the detailed CPAN module installation guide.