Module: JobTick::WheneverSetup
- Defined in:
- lib/jobtick/whenever_setup.rb
Overview
Overrides Whenever's built-in job types to wrap execution with jobtick pings.
Usage — add one line to config/schedule.rb:
JobTick::WheneverSetup.install!(self)
This replaces the :runner, :rake, and :command job types so that every scheduled job automatically sends started/completed/failed heartbeats without any per-job configuration. The monitor key is injected as a literal job option (:jobtick_key) rather than recomputed in shell, so it always matches the key Parsers::Whenever reads back out of the generated crontab.
Constant Summary collapse
- TEMPLATES =
{ runner: "cd :path && bundle exec rails runner ':task' :output", rake: "cd :path && bundle exec rake :task :output", command: ":task :output" }.freeze
Class Method Summary collapse
Class Method Details
.install!(schedule) ⇒ Object
35 36 37 38 39 40 41 42 43 44 45 |
# File 'lib/jobtick/whenever_setup.rb', line 35 def self.install!(schedule) endpoint = JobTick.config.endpoint TEMPLATES.each { |type, inner| schedule.job_type(type, wrap(endpoint, inner)) } # Prepended after job_type defines the singleton methods above, but order # doesn't matter for resolution: a prepended module always sits ahead of # the singleton class in the ancestor chain, so this always wins and # `super` always reaches the method job_type just defined. schedule.singleton_class.prepend(KEY_INJECTOR) end |