The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Ubic - flexible perl-based service manager

VERSION

version 1.14

SYNOPSIS

    Ubic->start("yandex-something");

    Ubic->stop("yandex-something");

    $status = Ubic->status("yandex-something");

DESCRIPTION

Ubic is a flexible perl-based service manager.

This module is a main frontend to ubic services.

Further directions:

if you are looking for general introduction to Ubic, follow this link: http://blogs.perl.org/mt/mt-search.fcgi?blog_id=310&tag=tutorial&limit=20;

if you want to manage ubic services from perl scripts, read this POD;

if you want to use ubic from command line, see ubic(1) and Ubic::Cmd;

if you want to write your own service, see Ubic::Service and other Ubic::Service::* modules. Check out Ubic::Run for integration with SysV init script system too.

CONSTRUCTOR

Ubic->new({ ... })

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 instance.

Constructor options (all of them are optional):

status_dir

Dir with persistent services' statuses.

service_dir

Name of dir with service descriptions (which will be used to construct root Ubic::Multiservice::Dir object)

lock_dir

Dir with services' locks.

LSB METHODS

See http://refspecs.freestandards.org/LSB_3.1.0/LSB-Core-generic/LSB-Core-generic/iniscrptact.html 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.

start($name)

Start service.

stop($name)

Stop service.

restart($name)

Restart service; start it if it's not running.

try_restart($name)

Restart service if it is enabled.

reload($name)

Reloads service if reloading is implemented; throw exception otherwise.

force_reload($name)

Reloads service if reloading is implemented, otherwise restarts it.

Does nothing if service is disabled.

status($name)

Get service status.

OTHER METHODS

enable($name)

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.

is_enabled($name)

Returns true value if service is enabled, false otherwise.

disable($name)

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.

cached_status($name)

Get cached status of enabled service.

Unlike other methods, it doesn't require user to be root.

do_custom_command($name, $command)
service($name)

Get service object by name.

has_service($name)

Check whether service $name exists.

services()

Get list of all services.

service_names()

Get list of names of all services.

root_service()

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 all services' tree.

compl_services($line)

Return list of autocompletion variants for given service prefix.

set_cached_status($name, $status)

Write new status into service's status file.

set_ubic_dir($dir)

Create and set ubic dir.

Ubic dir is a directory with service statuses and locks. By default, ubic dir is /var/lib/ubic, but in tests you may want to change it.

These settings will be propagated into subprocesses using environment, so following code works:

    Ubic->set_ubic_dir('tfiles/ubic');
    Ubic->set_service_dir('etc/ubic/service');
    system('ubic start some_service');
    system('ubic stop some_service');
set_service_dir($dir)

Set ubic services dir.

INTERNAL METHODS

You don't need to call these, usually.

status_file($name)

Get status file name by service's name.

status_obj($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.

status_obj_ro($name)

Get readonly, nonlocked status persistent object by service's name.

lock($name)

Acquire lock object for given service.

You can lock one object twice from the same process, but not from different processes.

do_sub($code)

Run any code and wrap result into Ubic::Result::Class object.

do_cmd($name, $cmd)

Run $cmd method from service $name and wrap any result or exception into Ubic::Result::Class object.

forked_call($callback)

Run $callback inside fork and return its return value.

Interaction happens through temporary file in $ubic-{tmp_dir}> dir.

SEE ALSO

Most Ubic-related links are collected on github wiki: http://github.com/berekuk/Ubic/wiki.

SUPPORT

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.

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.