Hi,
I searched up of google and found this thread. This is how I got my custom
code executed on process_exit:
Create a god/contact subclass like this:
require 'god/contact'
class DelayedJobUnlockingNotifier < God::Contact
def notify(message, time, priority, category, host)
if pid = (message.match(/process (?<pid>.*) exited/) || {})['pid']
`bundle exec rake RAILS_ENV=#{RAILS_ENV} PID=#{pid}
delayed_job:recover_locked_jobs`
applog(nil, :info, "delayed_job_unlocking_notifier: ran rake task to
unlock locked jobs for PID: #{pid}")
end
rescue Object => e
applog(nil, :info, "delayed_job_unlocking_notifier: failed to unlock
locked jobs for PID: #{pid}")
applog(nil, :debug, e.backtrace.join("\n"))
end
end
If your godfile on top:
require APPLICATION_ROOT +
'/lib/god/contacts/delayed_job_unlocking_notifier'
God.contact(:delayed_job_unlocking_notifier) do |c|
c.name = 'stuck_jobs_unlocker'
end
and then in the watch block
w.transition(:up, :start) do |on|
on.condition(:process_exits) do |c|
c.notify = 'stuck_jobs_unlocker'
end
end
Only problem is not that you cannot customize the parameters sent to the
notifier so I had to parse out PID from the message sent.
--
You received this message because you are subscribed to the Google Groups
"god.rb" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/god-rb.
For more options, visit https://groups.google.com/groups/opt_out.