[Bps-public-commit] smokingit-worker branch, master, updated. c5743bb4874d3af667fb3c887495cb5ec89b7d2c

Alex Vandiver alexmv at bestpractical.com
Wed Mar 14 14:19:40 EDT 2012


The branch, master has been updated
       via  c5743bb4874d3af667fb3c887495cb5ec89b7d2c (commit)
       via  2e89f6a46abc76ba598bc676e68f2511de5e158e (commit)
       via  93f6ae0197a957c4b37b1c445d0be677f526817f (commit)
      from  17c6ec21c69b6ed9509ddcb26c2dd35db7a1f28d (commit)

Summary of changes:
 bin/smokingit-worker    |   30 ++++++++++++++++++++++++++++--
 lib/Smokingit/Worker.pm |    5 +++--
 2 files changed, 31 insertions(+), 4 deletions(-)

- Log -----------------------------------------------------------------
commit 93f6ae0197a957c4b37b1c445d0be677f526817f
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Dec 27 17:21:05 2011 -0500

    Use Getopt::Long for simple option parsing

diff --git a/bin/smokingit-worker b/bin/smokingit-worker
index 2f551c0..c25b62b 100755
--- a/bin/smokingit-worker
+++ b/bin/smokingit-worker
@@ -4,9 +4,32 @@ use strict;
 use warnings;
 use lib 'lib';
 use Smokingit::Worker;
+use Getopt::Long;
+use Socket qw//;
+
+my $jobs    = 5;
+my $repos   = "repos";
+my $servers = ['127.0.0.1:4730'];
+
+GetOptions(
+    "jobs|j=i",                   \$jobs,
+    "repo-path|repos|r=s",        \$repos,
+    "gearman-server|server|s=s@", \$servers,
+) or die "Invalid options";
+
+die "Repository path $repos isn't writable!\n" unless -w $repos;
+
+for my $s (@{$servers}) {
+    my ($host, $port) = split ':', $s, 2;
+    $port ||= 4730;
+    my $packed = Socket::inet_aton($host);
+    die "Can't resolve server $host!\n" unless $packed;
+    $s = Socket::inet_ntoa($packed) . ":" . $port;
+}
 
 my $worker = Smokingit::Worker->new(
-    repo_path   => "repos",
-    job_servers => ['127.0.0.1:4730'],
+    max_jobs    => $jobs,
+    repo_path   => $repos,
+    job_servers => $servers,
 );
 $worker->run;

commit 2e89f6a46abc76ba598bc676e68f2511de5e158e
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 00:48:06 2012 -0400

    Use IO::Socket::INET to check connectivity, as well as resolve the hostname

diff --git a/bin/smokingit-worker b/bin/smokingit-worker
index c25b62b..f969761 100755
--- a/bin/smokingit-worker
+++ b/bin/smokingit-worker
@@ -5,7 +5,7 @@ use warnings;
 use lib 'lib';
 use Smokingit::Worker;
 use Getopt::Long;
-use Socket qw//;
+use IO::Socket::INET;
 
 my $jobs    = 5;
 my $repos   = "repos";
@@ -22,9 +22,12 @@ die "Repository path $repos isn't writable!\n" unless -w $repos;
 for my $s (@{$servers}) {
     my ($host, $port) = split ':', $s, 2;
     $port ||= 4730;
-    my $packed = Socket::inet_aton($host);
-    die "Can't resolve server $host!\n" unless $packed;
-    $s = Socket::inet_ntoa($packed) . ":" . $port;
+
+    my $socket = IO::Socket::INET->new( PeerHost => "$host:$port" );
+    die "Connect to $s failed: $1\n"
+        if ($@ || "") =~ /^IO::Socket::INET: (.*)/;
+
+    $s = $socket->peerhost . ":" . $port;
 }
 
 my $worker = Smokingit::Worker->new(

commit c5743bb4874d3af667fb3c887495cb5ec89b7d2c
Author: Alex Vandiver <alexmv at bestpractical.com>
Date:   Tue Mar 13 02:15:04 2012 -0400

    There is no reason to wait for the ack from the server
    
    If it fails, we'll have to redo it anyways, so do it asyncronously.

diff --git a/lib/Smokingit/Worker.pm b/lib/Smokingit/Worker.pm
index 79402a3..242e15c 100644
--- a/lib/Smokingit/Worker.pm
+++ b/lib/Smokingit/Worker.pm
@@ -164,8 +164,9 @@ sub run_tests {
         for keys %{$aggregator->{parser_for}};
     $result->{aggregator} = $aggregator;
 
-    $self->client->do_task(post_results => nfreeze($result))
-        or die "Can't send task!";
+    $self->client->dispatch_background(
+        post_results => nfreeze($result)
+    );
 
     # Clean out
     $cleanup->();

-----------------------------------------------------------------------



More information about the Bps-public-commit mailing list