Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Contact Us
Online Help
Domain Status
Man Pages

Virtual Servers

Topology Map

Server Agreement
Year 2038

USA Flag



Man Pages

Manual Reference Pages  -  UBIC (3)

.ds Aq ’


Ubic - polymorphic service manager



version 1.58


    Configure ubic:
    $ ubic-admin setup

    Write the service config:
    $ cat >/etc/ubic/service/foo.ini
    bin = /usr/bin/

    Start your service:
    $ ubic start foo

    Enjoy your daemonized, monitored service.


This module is a perl frontend to ubic services.

It is a singleton OOP class. All of its methods should be invoked as class methods:

    my $status = Ubic->status(foo);


Ubic is a polymorphic service manager.

Further directions:

if you are looking for a general introduction to Ubic, see Ubic::Manual::Intro;

if you want to use ubic from the command line, see ubic;

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

if you want to write your own service, see Ubic::Service and other Ubic::Service::* modules.


<B>Ubic->new({ ... })B> 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.

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):
service_dir Name of dir with service descriptions (which will be used to construct root Ubic::Multiservice::Dir object).
data_dir Dir into which ubic stores all of its data (locks, status files, tmp files).


See LSB documentation <> for init-script method specifications.

Following methods are trying to conform, except that all dashes in method names are replaced with underscores.

These methods return the result objects, i.e., instances of the Ubic::Result::Class class.
<B>start($name)B> Start the service.
<B>stop($name)B> Stop the service.
<B>restart($name)B> Restart the service; start it if it’s not running.
<B>try_restart($name)B> Restart the service if it is enabled.
<B>reload($name)B> Reload the service.

This method will do reloading if the service implements reload(); it will throw an exception otherwise.

<B>force_reload($name)B> Reload the service if reloading is implemented, otherwise restart it.

Does nothing if service is disabled.

<B>status($name)B> Get the service status.


<B>enable($name)B> Enable the service.

Enabled service means that service <B>shouldB> be running.

Watchdog will periodically check its status, attempt to restart it and mark it as broken if it won’t succeed.

<B>is_enabled($name)B> Check whether the service is enabled.

Returns true or false.

<B>disable($name)B> Disable the service.

Disabled service means that the service is ignored by ubic.

Its state will no longer be checked by the watchdog, and ubic status will report that the service is down.

<B>cached_status($name)B> Get cached status of the service.

Unlike other methods, it can be invoked by any user.

<B>do_custom_command($name, B>$command<B>)B> Execute the custom command $command for the given service.
<B>service($name)B> Get service object by name.
<B>has_service($name)B> Check whether the service named $name exists.
<B>B>services()<B>B> Get the list of all services.
<B>B>service_names()<B>B> Get the list of all service names.
<B>B>root_service()<B>B> Get the root multiservice object.

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.

<B>compl_services($line)B> Get the list of autocompletion variants for a given service prefix.
<B>set_cached_status($name, B>$status<B>)B> Write the new status into the service’s status file.
<B>B>get_data_dir()<B>B> Get the data dir.
<B>set_data_dir($dir)B> Set the 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 chosen).

This setting will be propagated into subprocesses using environment, so the following code works:

    system(ubic start some_service);
    system(ubic stop some_service);

<B>set_ubic_dir($dir)B> Deprecated. This method got renamed to set_data_dir().
<B>set_default_user($user)B> Set default user for all services.

This is a simple proxy for Ubic::Settings->default_user($user).

<B>B>get_service_dir()<B>B> Get the ubic services dir.
<B>set_service_dir($dir)B> Set the ubic services dir.


You shouldn’t call these from a code which doesn’t belong to core Ubic distribution.

These methods can be changed or removed without further notice.
<B>status_file($name)B> Get the status file name by a service’s name.
<B>status_obj($name)B> Get the status persistent object by a 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.

<B>status_obj_ro($name)B> Get the readonly, nonlocked status persistent object (see Ubic::Persistent) by a service’s name.
<B>access_guard($name)B> Get an access guard (Ubic::AccessGuard object) for the given service.
<B>lock($name)B> Acquire lock object for given service.

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

<B>do_sub($code)B> Run any code and wrap any result or exception into a result object.
<B>do_cmd($name, B>$cmd<B>)B> Run $cmd method from the service named $name and wrap any result or exception in a result object.
<B>forked_call($callback)B> Run a $callback in a subprocess and return its return value.

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


Andrei Mishchenko <>

Yury Zavarin <>

Dmitry Yashin

Christian Walde <>

Ivan Bessarabov <>

Oleg Komarov <>

Andrew Kirkpatrick <>


Most Ubic-related links are collected on github wiki: <>.

Daemon::Control and Proc::Launcher provide the start/stop/status style mechanisms for init scripts and apachectl-style commands.

Server::Control is an apachectl-style, heavyweight subclassable module for handling network daemons.

ControlFreak - process supervisor, similar to Ubic in its command-line interface.

There are also App::Daemon, App::Control and Supervisor.


Our IRC channel is irc://

There’s also a mailing list at Send an empty message to to subscribe.


Vyacheslav Matyukhin <>


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.

Search for    or go to Top of page |  Section 3 |  Main Index

perl v5.20.3 UBIC (3) 2015-01-27

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with manServer 1.07.