V
3  
Tags
Attachments
Dobrica Pavlinušić's random unstructured stuff
Gearman


Links

Implementations

Documentation

Cookbook

  • gearman

    0.install.sh

    gearman/0.install.sh
    apt-get install libgearman-client-perl

    gearman.pl

    • simple perl command-line client depenent only on libgearman-client-perl which is in etch 2010-05-01 12:49
    gearman/gearman.pl
    #!/usr/bin/perl
    
    use warnings;
    use strict;
    
    use Data::Dump qw(dump);
    use Getopt::Long;
    use Gearman::Worker;
    
    my $host = '10.60.0.244:4730';
    my $function = 'test';
    
    GetOptions(
    	'host' => \$host,
    	'function' => \$function,
    ) || die $!;
    
    
    my $worker = Gearman::Worker->new;
    $worker->job_servers( $host );
    $worker->register_function( $function => sub {
    	my $job = $_[0];
    	my $arg = $_[0]->arg;
    	warn "# job ",dump($job);
    });
    warn "# worker ",dump($worker);
    $worker->work while 1;
    
    =for client
    
    my $client = Gearman::Client->new;
    $client->job_servers($host);
    
    # running a single task
    my $result_ref = $client->do_task("add", "1+2");
    print "1 + 2 = $$result_ref\n";
    
    # waiting on a set of tasks in parallel
    my $taskset = $client->new_task_set;
    $taskset->add_task( "add" => "1+2", {
    	on_complete => sub { ... }
    });
    
    $taskset->add_task( "divide" => "5/0", {
    	on_fail => sub { print "divide by zero error!\n"; },
    });
    $taskset->wait;
    
    =cut

    grep_logs.sh

    gearman/grep_logs.sh
    #!/bin/sh -x
    
    # echo 'error' | gearman -f grep_logs
    
    if [ -z "$1" ] ; then
    	hostname=`hostname`
    	exec /srv/gearmand/bin/gearman -h 10.60.0.244 -w -f grep_$hostname $0 $hostname
    fi
    
    read pattern
    grep $pattern /var/log/*.log



 

Upload Files

Click "Browse" to find the file you want to upload. When you click "Upload file" your file will be uploaded and added to the list of attachments for this page.

Maximum file size: 50MB

 
 
 
File Name Author Date Uploaded Size

Save Page As

Enter a meaningful and distinctive title for your page.

Page Title:

Tip: You'll be able to find this page later by using the title you choose.

Page Already Exists

There is already a page named XXX. Would you like to:

Save with a different name:

Save the page with the name "XXX"

Append your text to the bottom of the existing page named: "XXX"

Upload Files

Click "Browse" to find the file you want to upload. When you click "Add file" this file will be added to the list of attachments for this page, and uploaded when you save the page.

 
 
 
Add Tags

Enter a tag and click "Add tag". The tag will be saved when you save the page.

Tag: 

Suggestions: