The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

    PJob::Server --- Simple POE Job Server 

SINOPISYS

    use PJob::Server;
    my $server = PJob::Server->new(port => '10086');
    $server->logfile('./.logfile');
    $server->log_commands(1);
    $server->add({ls => 'ls ~/', run => 'perl ~/test.pl'},'ls');
    $server->run();

DESCRIPTION

    PJob::Server is a simple POE Job Server module, it provide you some api to write a job server very quickly.
new

Create a PJob::Server object. The available arguments are:

    port            : port to listen. 32800 by default
    jobs            : available programs
    logfile         : log file name
    log_commands    : log the command runed by the client
    allowed_hosts   : hosts' ip that are allowed to run job on this server
    max_connections : default is set to -1, means no limit
add

add some programs, it receive both hashref and scalar. The key of the hashref is alias of the program. when scalar, the alias and the program have the same value.

job_dispatch
    $ser->job_dispatch('127.0.0.1' => [qw/ls ps/,{cat => 'cat file'}], '*' => ['pwd']);

dispatch available job to clients, receive client ip and its job table. * means common jobs which can be dispatched to all clients. Job table should be a arrayref. Jobs must be defined by $self->add except the situation that the element is a hashref, at this time, $self->add is called to add new job.

run

run the server, no argument needed.

SEE ALSO

    L<POE>,L<Moose>

AUTHOR

    woosley.xu<redicaps@gmail.com>

COPYRIGHT & LICENSE

This software is copyright (c) 2009 by woosley.xu.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.