Permalink
Switch branches/tags
Nothing to show
Find file
Fetching contributors…
Cannot retrieve contributors at this time
62 lines (49 sloc) 1.56 KB
require "sklaventreiber/version"
require "sklaventreiber/config"
require "sklaventreiber/herokuconnection"
module Sklaventreiber
module WorkerPlugin
module InstanceMethods
def before_create
if Sklaventreiber::Config::SKLAVENTREIBER_LOG
puts "Sklaventreiber: Job created."
end
Sklaventreiber::HerokuConnection.init()
# if there is no worker hired
if ( Sklaventreiber::HerokuConnection.is_fired?() )
# then hire one
Sklaventreiber::HerokuConnection.hire_worker()
end
super
end
# problem: Der Hook wird nicht aufgerufen --> warum?
def before_destroy
super
if Sklaventreiber::Config::SKLAVENTREIBER_LOG
puts "Sklaventreiber: Job #{self.id} destroyed."
end
Sklaventreiber::HerokuConnection.init()
# check if there are uncompleted jobs left
if ( Navvy::Job.filter( :failed_at => nil, :completed_at => nil ).count == 0 )
# then fire worker
Sklaventreiber::HerokuConnection.fire_worker()
end
end
# problem: Der Hook wird nicht aufgerufen --> warum?
def after_update
super
if Sklaventreiber::Config::SKLAVENTREIBER_LOG
puts "Sklaventreiber: Job #{self.id} updated."
end
Sklaventreiber::HerokuConnection.init()
if self.ran? then
# check if there are uncompleted jobs left
if ( Navvy::Job.filter( :failed_at => nil, :completed_at => nil ).count == 0 )
# then fire worker
Sklaventreiber::HerokuConnection.fire_worker()
end
end
end
end
end
end