lib/buildbox/client.rb in buildbox-0.0.2 vs lib/buildbox/client.rb in buildbox-0.0.3

- old
+ new

@@ -16,15 +16,18 @@ daemonize if @options[:daemon] pid_file.save loop do reload_configuration - process_build_queue + Buildbox::Queue.new.process wait_for_interval end rescue => e - api.crash(e, :build => @build) + Buildbox.logger.error "#{e.class.name}: #{e.message}" + e.backtrace.each { |line| Buildbox.logger.error line } + + api.crash(e) ensure pid_file.delete end end @@ -49,22 +52,10 @@ response = api.register(:uuid => worker_uuid, :hostname => `hostname`.chomp) Buildbox.configuration.update :worker_uuid, response.payload[:uuid] end - def process_build_queue - scheduled = api.builds.payload.first - - if scheduled - # store build in an instance variable so we can report on it in - # the event of a crash - @build = Build.new(scheduled) - Buildbox::Worker.new(@build, api).run - @build = nil - end - end - def reload_configuration Buildbox.configuration.reload end def wait_for_interval @@ -77,9 +68,12 @@ if pid_file.exist? Buildbox.logger.error "Process (#{pid_file.pid} - #{pid_file.path}) is already running." exit 1 end + end + + def worker end def api @api ||= Buildbox::API.new(:api_key => Buildbox.configuration.api_key) end