From 19f0465bd8ca1792390c55b97d558a8b7fc0c908 Mon Sep 17 00:00:00 2001 From: Marius Gavrilescu Date: Mon, 9 Feb 2015 10:00:06 +0200 Subject: [PATCH] Re-add multiple daemon support --- lib/Gruntmaster/Daemon.pm | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/lib/Gruntmaster/Daemon.pm b/lib/Gruntmaster/Daemon.pm index 3a83692..7b41d66 100644 --- a/lib/Gruntmaster/Daemon.pm +++ b/lib/Gruntmaster/Daemon.pm @@ -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); } } -- 2.39.2