View on
MetaCPAN
Kazuho Oku > Parallel-Scoreboard-0.02 > Parallel::Scoreboard

Download:
Parallel-Scoreboard-0.02.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  1
View/Report Bugs
Module Version: 0.02   Source   Latest Release: Parallel-Scoreboard-0.08

NAME ^

Parallel::Scoreboard - A scoreboard for monitoring status of many processes

SYNOPSIS ^

  use Parallel::Scoreboard;

  my $scoreboard = new Parallel::Scoreboard(
      base_dir => '/tmp/my_scoreboard'
  ...

  # in each worker process
  $scoreboard->update('this is my current status');

  # to read status of all worker processes
  my $stats = $scoreboard->read_all();
  for my $pid (sort { $a <=> $b } keys %$stats) {
      print "status for pid:$pid is: ", $stats->{$pid}, "\n";
  }

DESCRIPTION ^

Parallel::Scoreboard is a pure-perl implementation of a process scoreboard. By using the module it is easy to create a monitor for many worker process, like the status module of the Apache HTTP server.

Unlike other similar modules, Parallel::Scoreboard is easy to use and has no limitation on the format or the length of the statuses to be stored. Any arbitrary data (like JSON or frozen perl object) can be saved by the worker processes as their status and read from the manager process.

METHODS ^

new(base_dir => $base_dir)

instantiation. Receives the directory name in which the scoreboard files will be stored. The directory will be created if it does not exist already.

update($status)

saves the status of the process

read_all()

reads the status of all worker processes that are alive and that have called update() more than once. Returned value is a hashref with process ids as keys and the statuses of each processes as corresponding values.

cleanup()

remove obsolete status files found in base_dir. The files are normally removed upon the termination of worker process, however they might be left unremoved if the worker process was killed for some reason. The detection and removal of the obsolete status files is performed by read_all() as well.

SEE ALSO ^

IPC::ScoreBoard Proc::Scoreboard

AUTHOR ^

Kazuho Oku <kazuhooku gmail.com>

LICENSE ^

This program is free software, you can redistribute it and/or modify it under the same terms as Perl 5.10.

syntax highlighting: