lib/woodhouse/runner.rb in woodhouse-0.1.2 vs lib/woodhouse/runner.rb in woodhouse-0.1.5

- old
+ new

@@ -25,20 +25,25 @@ include Celluloid def initialize(worker, config) @worker = worker @config = config + @status_client = Woodhouse::Watchdog.client @config.logger.debug "Thread for #{@worker.describe} ready and waiting for jobs" end # Implement this in a subclass. When this message is received by an actor, it should # finish whatever job it is currently doing, gracefully disconnect from AMQP, and # stop the subscribe loop. def spin_down raise NotImplementedError, "implement #spin_down in a subclass of Woodhouse::Runner" end + def current_status + @status + end + private # Implement this in a subclass. When this message is received by an actor, it should # connect to AMQP and start pulling jobs off the queue. This method should not finish # until spin_down is called. @@ -51,10 +56,15 @@ @worker.accepts_job?(job) end # Executes a Job. See Woodhouse::JobExecution. def service_job(job) # :doc: - @config.logger.debug "Servicing job for #{@worker.describe}" + status :servicing Woodhouse::JobExecution.new(@config, job).execute + end + + def status(stat, message = nil) + message ||= @worker.describe + @status_client.report stat, message end end