.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .nr rF 0 .if \n(.g .if rF .nr rF 1 .if (\n(rF:(\n(.g==0)) \{\ . if \nF \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} . \} .\} .rr rF .\" ======================================================================== .\" .IX Title "Parallel::Prefork::SpareWorkers 3pm" .TH Parallel::Prefork::SpareWorkers 3pm "2021-01-04" "perl v5.32.0" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Parallel::Prefork::SpareWorkers \- A prefork server framework with support for (min|max)spareservers .SH "SYNOPSIS" .IX Header "SYNOPSIS" .Vb 1 \& use 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 => \*(AqTERM\*(Aq, \& HUP => \*(AqTERM\*(Aq, \& USR1 => undef, \& }, \& }); \& \& while ($pm\->signal_received ne \*(AqTERM\*(Aq) { \& load_config(); \& $pm\->start and next; \& \& # do what ever you like, as follows \& while (my $sock = $listener\->accept()) { \& $pm\->set_status(\*(AqA\*(Aq); \& ... \& $sock\->close(); \& $pm\->set_status(STATUS_IDLE); \& } \& \& $pm\->finish; \& } \& \& $pm\->wait_all_children; .Ve .SH "DESCRIPTION" .IX Header "DESCRIPTION" \&\f(CW\*(C`Parallel::Prefork::SpareWorkers\*(C'\fR is a subclass of \f(CW\*(C`Parallel::Prefork\*(C'\fR that supports setting minimum and maximum number of spare worker processes, a feature commonly found in network servers. The module adds to \f(CW\*(C`Parallel::Prefork\*(C'\fR several initialization parameters, constants, and a method to set state of the worker processes. .SH "METHODS" .IX Header "METHODS" .SS "new" .IX Subsection "new" Instantiation. \f(CW\*(C`Parallel::Prefork::ShpareWorkers\*(C'\fR recognizes the following parameters in addition to those defined by \f(CW\*(C`Parallel::Prefork\*(C'\fR. The parameters can be accessed using accessors with same names as well. .PP \fImin_spare_workers\fR .IX Subsection "min_spare_workers" .PP minimum number of spare workers (mandatory) .PP \fImax_spare_workers\fR .IX Subsection "max_spare_workers" .PP maxmum number of spare workers (default: max_workers) .PP \fIheartbeat\fR .IX Subsection "heartbeat" .PP a fractional period (in seconds) of child amount checking. Do not use very small numbers to avoid frequent use of \s-1CPU\s0 (default: 0.25) .PP \fIscoreboard_file\fR .IX Subsection "scoreboard_file" .PP filename of scoreboard. If not set, \f(CW\*(C`Parallel::Prefork::SpareWorkers\*(C'\fR will create a temporary file. .SS "set_status" .IX Subsection "set_status" sets 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 \f(CW\*(C`STATUS_IDLE\*(C'\fR '_' once the worker enters idle state. The other reserved character is \f(CW\*(C`STATUS_NEXIST\*(C'\fR '.' which should never be set directly by applications. .SH "CONSTANTS" .IX Header "CONSTANTS" .SS "\s-1STATUS_NEXIST\s0" .IX Subsection "STATUS_NEXIST" scoreboard status character '.', meaning no worker process is assigned to the slot of the scoreboard. Applications should never set this value directly. .SS "\s-1STATUS_IDLE\s0" .IX Subsection "STATUS_IDLE" scoreboard status character '_', meaning that a worker process is in idle state .SH "LICENSE" .IX Header "LICENSE" This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself. .PP See http://www.perl.com/perl/misc/Artistic.html