From a131de53f1ff1b29358f549aa11f2877ff62c7ad Mon Sep 17 00:00:00 2001 From: Luke Melia Date: Wed, 9 Jun 2010 09:16:17 -0400 Subject: [PATCH] Upon boot, hydra workers will now require hydra_worker_init.rb in the current working directory if it is present. --- lib/hydra/worker.rb | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/lib/hydra/worker.rb b/lib/hydra/worker.rb index b4f7b47..c0b6f2b 100644 --- a/lib/hydra/worker.rb +++ b/lib/hydra/worker.rb @@ -20,6 +20,7 @@ module Hydra #:nodoc: @runners = [] @listeners = [] + load_worker_initializer boot_runners(opts.fetch(:runners) { 1 }) @io.write(Hydra::Messages::Worker::WorkerBegin.new) @@ -28,7 +29,15 @@ module Hydra #:nodoc: @runners.each{|r| Process.wait r[:pid] } end - + def load_worker_initializer + if File.exist?('./hydra_worker_init.rb') + trace('Requiring hydra_worker_init.rb') + require 'hydra_worker_init' + else + trace('hydra_worker_init.rb not present') + end + end + # message handling methods # When a runner wants a file, it hits this method with a message.