Re-add multiple daemon support
authorMarius Gavrilescu <marius@ieval.ro>
Mon, 9 Feb 2015 08:00:06 +0000 (10:00 +0200)
committerMarius Gavrilescu <marius@ieval.ro>
Mon, 9 Feb 2015 08:00:06 +0000 (10:00 +0200)
lib/Gruntmaster/Daemon.pm

index 3a83692..7b41d66 100644 (file)
@@ -144,14 +144,13 @@ sub got_job{
        my $id = $job->id;
        get_logger->debug("Taking job $id...");
        my $daemon = hostname . ":$$";
-       $job->update({daemon => $daemon});
-       #if (set_job_daemon $job, hostname . ":$$") {
-       if (1) {
+       $job->update({daemon => $daemon}, {where => {daemon => undef}})->discard_changes;
+       if ($job->daemon eq $daemon) {
                get_logger->debug("Succesfully taken job $id");
                process_job $job;
                get_logger->debug("Job $id done");
        } else {
-               get_logger->debug("Job $id already taken");
+               get_logger->debug("Job $id already taken by " . $job->daemon);
        }
 }
 
This page took 0.026565 seconds and 4 git commands to generate.