<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">
  <title xmlns="http://www.w3.org/2005/Atom">Dobrica Pavlinušić's random unstructured stuff: Gearman</title>
  <id xmlns="http://www.w3.org/2005/Atom">https://saturn.ffzg.hr/rot13/</id>
  <link xmlns="http://www.w3.org/2005/Atom" type="text/html" rel="alternate" href="https://saturn.ffzg.hr/rot13/index.cgi?gearman"/>
  <link xmlns="http://www.w3.org/2005/Atom" type="application/atom+xml" rel="self" href="https://saturn.ffzg.hr%2C%20saturn.ffzg.hr:443/feed/workspace/rot13?page=gearman;type=Atom"/>
  <updated xmlns="http://www.w3.org/2005/Atom">2010-05-04T10:02:46Z</updated>
  <entry xmlns="http://www.w3.org/2005/Atom">
    <title xmlns="http://www.w3.org/2005/Atom">Gearman</title>
    <link xmlns="http://www.w3.org/2005/Atom" type="text/html" rel="alternate" href="https://saturn.ffzg.hr/rot13/index.cgi?gearman"/>
    <content xmlns="http://www.w3.org/2005/Atom" type="html">&lt;div&gt;Creator: Dobrica Pavlinušić&lt;/div&gt;&lt;hr/&gt;&lt;div&gt;Tags: gearman&lt;/div&gt;&lt;hr/&gt;&lt;div class="wiki"&gt;
&lt;div class="nlw_phrase"&gt;&lt;table class="wafl_container"&gt;
  &lt;tr&gt;
    &lt;td&gt;
      &lt;div class="wafl_box"&gt;
        
          &lt;div class="wafl_titlebox"&gt;
            &lt;div class="wafl_title"&gt;
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            &lt;/div&gt;
          &lt;/div&gt;
          &lt;div class="wafl_items"&gt;
            
              &lt;div class="wiki"&gt;
&lt;ul&gt;
&lt;li&gt;&lt;span class="nlw_phrase"&gt;&lt;a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#links"&gt;Dobrica Pavlinušić's random unstructured stuff (Links)&lt;/a&gt;&lt;!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Links} --&gt;&lt;/span&gt;&lt;/li&gt;

&lt;ul&gt;
&lt;li&gt;&lt;span class="nlw_phrase"&gt;&lt;a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#implementations"&gt;Dobrica Pavlinušić's random unstructured stuff (Implementations)&lt;/a&gt;&lt;!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Implementations} --&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span class="nlw_phrase"&gt;&lt;a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#documentation"&gt;Dobrica Pavlinušić's random unstructured stuff (Documentation)&lt;/a&gt;&lt;!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Documentation} --&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;li&gt;&lt;span class="nlw_phrase"&gt;&lt;a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#cookbook"&gt;Dobrica Pavlinušić's random unstructured stuff (Cookbook)&lt;/a&gt;&lt;!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Cookbook} --&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;/div&gt;

            
            
          &lt;/div&gt;
        
      &lt;/div&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
&lt;/table&gt;
&lt;!-- wiki: {toc: }
--&gt;&lt;/div&gt;&lt;br /&gt;&lt;br /&gt;&lt;h1 id="links"&gt;Links&lt;/h1&gt;
&lt;h2 id="implementations"&gt;Implementations&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a target="_blank" title="(external link)" href="http://code.sixapart.com/trac/gearman"&gt;http://code.sixapart.com/trac/gearman&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a target="_blank" title="(external link)" href="http://gearman.org/"&gt;http://gearman.org/&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h2 id="documentation"&gt;Documentation&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;protocol: &lt;a target="_blank" title="(external link)" href="http://gearman.org/index.php?id=protocol"&gt;http://gearman.org/index.php?id=protocol&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;HTTP: &lt;a target="_blank" title="(external link)" href="http://oddments.org/?p=68"&gt;http://oddments.org/?p=68&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;h1 id="cookbook"&gt;Cookbook&lt;/h1&gt;
&lt;div class="nlw_phrase"&gt;&lt;div class="fetchrss_box"&gt;
  &lt;div class="fetchrss_titlebox"&gt;
    
  
  
 &lt;div class="fetchrss_title"&gt;
   &lt;a href="http://sysadmin-cookbook.rot13.org/#gearman"&gt;Sysadmin Cookbook :: gearman&lt;/a&gt;
 &lt;/div&gt;


  &lt;/div&gt;
  
 &lt;ul class="fetchrss_items"&gt;
  
  
    
  &lt;li class="fetchrss_item"&gt;
    &lt;a href="http://sysadmin-cookbook.rot13.org/#gearman"&gt;gearman&lt;/a&gt;
    
      &lt;p class="fetchrss_description"&gt;
        &lt;h4&gt;0.install.sh&lt;/h4&gt;
&lt;ul class=changes&gt;&lt;li&gt;install German::Client from package
 &lt;a class="date" title="r204" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/revision?rev=204"&gt;2010-05-02 16:24&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a class="path" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/view/recepies/gearman/0.install.sh"&gt;gearman/0.install.sh&lt;/a&gt;&lt;pre class=content&gt;apt-get install libgearman-client-perl&lt;/pre&gt;
&lt;h4&gt;gearman.pl&lt;/h4&gt;
&lt;ul class=changes&gt;&lt;li&gt;simple perl command-line client depenent only on libgearman-client-perl which is in etch
 &lt;a class="date" title="r203" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/revision?rev=203"&gt;2010-05-01 12:49&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a class="path" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/view/recepies/gearman/gearman.pl"&gt;gearman/gearman.pl&lt;/a&gt;&lt;pre class=content&gt;#!/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' =&amp;gt; \$host,
	'function' =&amp;gt; \$function,
) || die $!;


my $worker = Gearman::Worker-&amp;gt;new;
$worker-&amp;gt;job_servers( $host );
$worker-&amp;gt;register_function( $function =&amp;gt; sub {
	my $job = $_[0];
	my $arg = $_[0]-&amp;gt;arg;
	warn &amp;quot;# job &amp;quot;,dump($job);
});
warn &amp;quot;# worker &amp;quot;,dump($worker);
$worker-&amp;gt;work while 1;

=for client

my $client = Gearman::Client-&amp;gt;new;
$client-&amp;gt;job_servers($host);

# running a single task
my $result_ref = $client-&amp;gt;do_task(&amp;quot;add&amp;quot;, &amp;quot;1+2&amp;quot;);
print &amp;quot;1 + 2 = $$result_ref\n&amp;quot;;

# waiting on a set of tasks in parallel
my $taskset = $client-&amp;gt;new_task_set;
$taskset-&amp;gt;add_task( &amp;quot;add&amp;quot; =&amp;gt; &amp;quot;1+2&amp;quot;, {
	on_complete =&amp;gt; sub { ... }
});

$taskset-&amp;gt;add_task( &amp;quot;divide&amp;quot; =&amp;gt; &amp;quot;5/0&amp;quot;, {
	on_fail =&amp;gt; sub { print &amp;quot;divide by zero error!\n&amp;quot;; },
});
$taskset-&amp;gt;wait;

=cut&lt;/pre&gt;
&lt;h4&gt;grep_logs.sh&lt;/h4&gt;
&lt;ul class=changes&gt;&lt;li&gt;simple grep_hostname worker
 &lt;a class="date" title="r202" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/revision?rev=202"&gt;2010-05-01 12:37&lt;/a&gt;&lt;/li&gt;&lt;/ul&gt;&lt;a class="path" href="http://svn.rot13.org/index.cgi/sysadmin-cookbook/view/recepies/gearman/grep_logs.sh"&gt;gearman/grep_logs.sh&lt;/a&gt;&lt;pre class=content&gt;#!/bin/sh -x

# echo 'error' | gearman -f grep_logs

if [ -z &amp;quot;$1&amp;quot; ] ; 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&lt;/pre&gt;
      &lt;/p&gt;
    
  &lt;/li&gt;

  
 &lt;/ul&gt;

&lt;/div&gt;
















&lt;!-- wiki: {fetchrss: http://sysadmin-=cookbook.rot13.org/rss/gearman.xml full}
--&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;
</content>
    <id xmlns="http://www.w3.org/2005/Atom">https://saturn.ffzg.hr/rot13/index.cgi?gearman</id>
    <author xmlns="http://www.w3.org/2005/Atom">
      <name xmlns="http://www.w3.org/2005/Atom">Dobrica Pavlinušić</name>
    </author>
    <updated xmlns="http://www.w3.org/2005/Atom">2010-05-04T10:02:46Z</updated>
    <category xmlns="http://www.w3.org/2005/Atom" term="gearman" label="gearman"/>
  </entry>
</feed>
