NAME

Gearman::Driver::Console - Management console

SYNOPSIS

$ ~/Gearman-Driver$ ./examples/driver.pl --console_port 12345 &
[1] 32890
$ ~/Gearman-Driver$ telnet localhost 12345
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
status
GDExamples::Sleeper::ZzZzZzzz   3       6       3
GDExamples::Sleeper::long_running_ZzZzZzzz      1       2       1
GDExamples::WWW::is_online      0       1       0
.

DESCRIPTION

By default Gearman::Driver provides a management console which can be used with a standard telnet client. It's possible to list all running worker processes as well as changing min/max processes on runtime.

Each successful command ends with a dot. If a command throws an error, a line starting with 'ERR' will be returned.

COMMANDS

All basic commands are implemented in Gearman::Driver::Console::Basic. It's very easy to extend this console with new commands. Every module found in namespace Gearman::Driver::Console::* will be loaded. Each of those modules has to be implemented as a Moose::Role. You've got access to two attributes/methods there:

So a new command could look like:

package Gearman::Driver::Console::List;

use Moose::Role;

sub list {
    my ($self) = @_;
    my @result = ();
    foreach my $job ( $self->driver->get_jobs ) {
        push @result, $job->name;
    }
    return @result;
}

1;

If you need to throw an error, just die and everything will work as expected (as long as you do not forget the \n):

package Gearman::Driver::Console::Broken;

use Moose::Role;

sub broken {
    my ($self) = @_;
    die "ERR this is a broken command\n";
}

sub get_max_processes {
    my ( $self, $job_name ) = @_;
    my $job = $self->get_job($job_name); # this automatically dies if job is not found
    return $job->max_processes;
}

1;

Yes, that's all...

$ ~/Gearman-Driver$ telnet localhost 47300
Trying ::1...
telnet: connect to address ::1: Connection refused
Trying fe80::1...
telnet: connect to address fe80::1: Connection refused
Trying 127.0.0.1...
Connected to localhost.
Escape character is '^]'.
list
GDExamples::Sleeper::ZzZzZzzz
GDExamples::Sleeper::long_running_ZzZzZzzz
GDExamples::WWW::is_online
.
broken
ERR this is a broken command
get_max_processes asdf
ERR invalid_job_name: asdf
get_max_processes GDExamples::Sleeper::ZzZzZzzz
6
.

AUTHOR

See Gearman::Driver.

COPYRIGHT AND LICENSE

See Gearman::Driver.

SEE ALSO