NAME

Clio::ProcessManager - Process manager

VERSION

version 0.02

SYNOPSIS

    my $process_manager = Clio::ProcessManager->new(
        c => $context,
    );

DESCRIPTION

Process manager is created on application start and manages all processes (Clio::Process).

Consumes the Clio::Role::HasContext and the Clio::Role::UUIDMaker.

ATTRIBUTES

processes

    while ( my ($id, $process) = each %{ $process_manager->processes } ) {
        print "Process $id is", ( $process->is_idle ? '' : ' not'), " idle\n";
    }

Container for all managed processes.

METHODS

start

    $process_manager->start;

Starts a number of processes equal to StartCommands and creates the idle processes maintanace loop.

create_process

    $process_manager->create_process( $cmd );

Create new Clio::Process

get_first_available

    $process_manager->get_first_available( %args );

Based on configuration returns first idle process or if none are availble creates a new one.

If $args{client_id} is present then process connected to this client will be returned.

total_count

    my $num_processes = $process_manager->total_count();

Returns number of managed processes.

stop_process

    my $stopped_process = $process_manager->stop_process( $process_id );

Shutdowns process and stops managing it.

CONFIGURATION

Based on the configuration starts new listening processes and stops the idle ones.

  • StartCommands

    Number of processes created at the application start.

  • MinSpareCommands

    Minimum number of idle processes.

  • MaxSpareCommands

    Maximum number of idle processes.

  • MaxCommands

    Maximum number of commands running at the same time.

  • MaxClientsPerCommand

    Maximum number of clients per process.

AUTHOR

Alex J. G. Burzyński <ajgb@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2012 by Alex J. G. Burzyński <ajgb@cpan.org>.

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