1Parallel::Prefork::SparUesWeorrkCeornst(r3i)buted Perl DPoacruamlelnetla:t:iPornefork::SpareWorkers(3)
2
3
4

NAME

6       Parallel::Prefork::SpareWorkers - A prefork server framework with
7       support for (min|max)spareservers
8

SYNOPSIS

10         use Parallel::Prefork::SpareWorkers qw(:status);
11
12         my $pm = Parallel::Prefork::SpareWorkers->new({
13           max_workers       => 40,
14           min_spare_workers => 5,
15           max_spare_workers => 10,
16           trap_signals      => {
17             TERM => 'TERM',
18             HUP  => 'TERM',
19             USR1 => undef,
20           },
21         });
22
23         while ($pm->signal_recieived ne 'TERM') {
24           load_config();
25           $pm->start and next;
26
27           # do what ever you like, as follows
28           while (my $sock = $listener->accept()) {
29             $pm->set_status('A');
30             ...
31             $sock->close();
32             $pm->set_status(STATUS_IDLE);
33           }
34
35           $pm->finish;
36         }
37
38         $pm->wait_all_children;
39

DESCRIPTION

41       "Parallel::Prefork::SpareWorkers" is a subclass of "Parallel::Prefork"
42       that supports setting minimum and maximum number of spare worker
43       processes, a feature commonly found in network servers.  The module
44       adds to "Parallel::Prefork" several initialization parameters,
45       constants, and a method to set state of the worker processes.
46

METHODS

48   new
49       Instantiation.  "Parallel::Prefork::ShpareWorkers" recognizes the
50       following parameters in addition to those defined by
51       "Parallel::Prefork".  The parameters can be accessed using accessors
52       with same names as well.
53
54       min_spare_workers
55
56       minimum number of spare workers (mandatory)
57
58       max_spare_workers
59
60       maxmum number of spare workers (default: max_workers)
61
62       scoreboard_file
63
64       filename of scoreboard.  If not set, "Parallel::Prefork::SpareWorkers"
65       will create a temporary file.
66
67   set_status
68       sets a single-byte character state of the worker process.  Worker
69       processes should set any character of their choice using the function
70       (but not one of the reserved characters) to declare that it is running
71       some kind of task.  Or the state should be set to "STATUS_IDLE" '_'
72       once the worker enters idle state.  The other reserved character is
73       "STATUS_NEXIST" '.' which should never be set directly by applications.
74

CONSTANTS

76   STATUS_NEXIST
77       scoreboard status character '.', meaning no worker process is assigned
78       to the slot of the scoreboard.  Applications should never set this
79       value directly.
80
81   STATUS_IDLE
82       scoreboard status character '_', meaning that a worker process is in
83       idle state
84

LICENSE

86       This program is free software; you can redistribute it and/or modify it
87       under the same terms as Perl itself.
88
89       See http://www.perl.com/perl/misc/Artistic.html
90
91
92
93perl v5.12.2                      2010-12-17Parallel::Prefork::SpareWorkers(3)
Impressum