|
NAMEParallel::Prefork::SpareWorkers - A prefork server framework with support for (min|max)spareserversSYNOPSISuse Parallel::Prefork::SpareWorkers qw(:status); my $pm = Parallel::Prefork::SpareWorkers->new({ max_workers => 40, min_spare_workers => 5, max_spare_workers => 10, trap_signals => { TERM => 'TERM', HUP => 'TERM', USR1 => undef, }, }); while ($pm->signal_received ne 'TERM') { load_config(); $pm->start and next; # do what ever you like, as follows while (my $sock = $listener->accept()) { $pm->set_status('A'); ... $sock->close(); $pm->set_status(STATUS_IDLE); } $pm->finish; } $pm->wait_all_children; DESCRIPTION"Parallel::Prefork::SpareWorkers" is a subclass of "Parallel::Prefork" that supports setting minimum and maximum number of spare worker processes, a feature commonly found in network servers. The module adds to "Parallel::Prefork" several initialization parameters, constants, and a method to set state of the worker processes.METHODSnewInstantiation. "Parallel::Prefork::ShpareWorkers" recognizes the following parameters in addition to those defined by "Parallel::Prefork". The parameters can be accessed using accessors with same names as well.min_spare_workers minimum number of spare workers (mandatory) max_spare_workers maxmum number of spare workers (default: max_workers) heartbeat a fractional period (in seconds) of child amount checking. Do not use very small numbers to avoid frequent use of CPU (default: 0.25) scoreboard_file filename of scoreboard. If not set, "Parallel::Prefork::SpareWorkers" will create a temporary file. set_statussets a single-byte character state of the worker process. Worker processes should set any character of their choice using the function (but not one of the reserved characters) to declare that it is running some kind of task. Or the state should be set to "STATUS_IDLE" '_' once the worker enters idle state. The other reserved character is "STATUS_NEXIST" '.' which should never be set directly by applications.CONSTANTSSTATUS_NEXISTscoreboard status character '.', meaning no worker process is assigned to the slot of the scoreboard. Applications should never set this value directly.STATUS_IDLEscoreboard status character '_', meaning that a worker process is in idle stateLICENSEThis program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.See http://www.perl.com/perl/misc/Artistic.html
Visit the GSP FreeBSD Man Page Interface. |