Yann Kerhervé

NAME

ControlFreak - a process supervisor

SYNOPSIS

    ## WARNING
    ## see L<cfkd> and L<cfkctl> manpages for how to run ControlFreak from
    ## the shell. This is the programatic interface used by these scripts.

    $ctrl = ControlFreak->new(
        log_config_file => $log_config_file,
    );
    $ctrl->run; # enter the event loop, returns only for exiting

    ## elsewhere in the eventloop
    $ctrl->add_socket($sock);
    $sock = $ctrl->socket($sockname);

    $svc = $ctrl->find_or_create($svcname);
    $ctrl->add_service($svc);
    $svc = $ctrl->service($svcname);

    @svcs = $ctrl->service_by_tag($tag);
    @svcs = $ctrl->services;

    $ctrl->destroy($svcname);

    $ctrl->set_console($con);
    $con = $ctrl->console;
    $log = $ctrl->log;

DESCRIPTION

This is the programmer documentation. Look into "Intro.pod" in ControlFreak for user documentation.

METHODS

new(%param)

  • config

    The absolute path to a initial config file.

services

Returns a list of ControlFreak::Service instances known to this controller.

sockets

Returns a list of ControlFreak::Socket instances known to this controller.

service($name)

Returns the service of name $name or nothing.

proxy($name)

Returns the proxy of name $name or nothing.

set_console

Takes a ControlFreak::Console instance in parameter and sets it as the console.

socket($name)

Returns the ControlFreak::Socket object of name $name or returns undef.

add_socket($socket)

Adds the $socket ControlFreak::Socket object passed in parameters to the list of socket this controller knows about.

If a socket by that name already exists, it returns undef, otherwise it returns a true value;

remove_socket($socket_name)

Removes the ControlFreak::Socket object by the name of $socket_name from the list of sockets this controller knows about.

Returns true if effectively removed.

add_proxy($proxy)

Adds the $proxy ControlFreak::Proxy object passed in parameters to the list of proxies this controller knows about.

If a proxy by that name already exists, it returns undef, otherwise it returns a true value;

remove_proxy($proxy_name)

Removes the ControlFreak::Proxy object by the name of $proxy_name from the list of proxies this controller knows about.

Returns true if effectively removed.

proxies

Returns a list of proxy objects.

find_or_create_svc($name)

Given a service name in parameter (a string), searches for an existing defined service with that name, if not found, then a new service is declared and returned.

find_or_create_sock($name)

Given a socket name in parameter (a string), searches for an existing defined socket with that name, if not found, then a new socket is declared and returned.

find_or_create_proxy($name)

Given a proxy name in parameter (a string), searches for an existing defined proxy with that name, if not found, then a new proxy is declared and returned.

logger

Returns the logger attached to the controller.

services_by_tag($tag)

Given a tag in parameter, returns a list of matching service objects.

services_from_args(%param)

Given a list of arguments (typically from the console commands) returns a list of ControlFreak::Service instances.

  • args

    The list of arguments to analyze.

  • err

    A callback called with the parsing errors of the arguments.

command_*

All accessible commands to the config and the console.

destroy($svc)

Removes any reference to $svc in the controller. The concerned service must be down in the first place.

shutdown

Cleanly exits all running commands, close all sockets etc...

AUTHOR

Yann Kerherve <yannk@cpan.org>

LICENSE

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.

SEE ALSO

I think the venerable (but hatred) daemontools is the ancestor of all supervisor processes. In the same class there is also runit and monit.

More recent modules which inspired ControlFreak are God and Supervisord in Python. Surprisingly I didn't find any similar program in Perl. Some ideas in ControlFreak are subtely different though.

EDIT: I've spotted Ubic recently on CPAN

"If you have kids you probably know what I mean";