1NAME 2 Parallel::Scoreboard - a scoreboard for monitoring status of many 3 workers 4 5SYNOPSIS 6 use Parallel::Scoreboard; 7 8 my $scoreboard = Parallel::Scoreboard->new( 9 base_dir => '/tmp/my_scoreboard' 10 ... 11 12 # in each worker process 13 $scoreboard->update('this is my current status'); 14 15 # to read status of all worker processes 16 my $stats = $scoreboard->read_all(); 17 for my $pid (sort { $a <=> $b } keys %$stats) { 18 print "status for pid:$pid is: ", $stats->{$pid}, "\n"; 19 } 20 21DESCRIPTION 22 Parallel::Scoreboard is a pure-perl implementation of a process 23 scoreboard. By using the module it is easy to create a monitor for many 24 worker process, like the status module of the Apache HTTP server. 25 26 Unlike other similar modules, Parallel::Scoreboard is easy to use and 27 has no limitation on the format or the length of the statuses to be 28 stored. Any arbitrary data (like JSON or frozen perl object) can be 29 saved by the worker processes as their status and read from the manager 30 process. 31 32METHODS 33 new(%args) 34 instantiation. Recognizes the following paramaters. The parameters can 35 be read using the read-only accessors with the same name. 36 37 base_dir => $base_dir 38 the directory name in which the scoreboard files will be stored. The 39 directory will be created if it does not exist already. Mandatory 40 parameter. 41 42 worker_id => sub { ... } 43 a subref that returns the id of the worker (if omitted, the module uses 44 $$ (process id) to distinguish between the workers) 45 46 update($status) 47 saves the status of the process 48 49 read_all() 50 reads the status of all worker processes that are alive and that have 51 called update() more than once. Returned value is a hashref with process 52 ids as keys and the statuses of each processes as corresponding values. 53 54 cleanup() 55 remove obsolete status files found in base_dir. The files are normally 56 removed upon the termination of worker process, however they might be 57 left unremoved if the worker process was killed for some reason. The 58 detection and removal of the obsolete status files is performed by 59 read_all() as well. 60 61SEE ALSO 62 IPC::ScoreBoard Proc::Scoreboard 63 64AUTHOR 65 Kazuho Oku <kazuhooku gmail.com> 66 67LICENSE 68 This program is free software, you can redistribute it and/or modify it 69 under the same terms as Perl 5.10. 70 71