Class: Ocular::Inputs::Cron::Input
- Defined in:
- lib/ocular/inputs/cron_input.rb
Defined Under Namespace
Classes: DSLProxy
Instance Attribute Summary collapse
-
#cron_enabled ⇒ Object
readonly
Returns the value of attribute cron_enabled.
-
#routes ⇒ Object
readonly
Returns the value of attribute routes.
-
#scheduler ⇒ Object
readonly
Returns the value of attribute scheduler.
Instance Method Summary collapse
- #disable ⇒ Object
- #enable ⇒ Object
-
#initialize(settings_factory) ⇒ Input
constructor
A new instance of Input.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(settings_factory) ⇒ Input
Returns a new instance of Input.
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 |
# File 'lib/ocular/inputs/cron_input.rb', line 31 def initialize(settings_factory) settings = settings_factory.get(:inputs).fetch(:cron, {}) @cron_enabled = true if settings[:lock] @cron_enabled = false end if settings[:enabled] == false ::Ocular.logger.info "Cron is disabled from settings" @cron_enabled = false end @scheduler = ::Rufus::Scheduler.new ::Ocular.logger.debug "Starting Rufus cron scheduler" if settings[:lock] and @cron_enabled == true Ocular.logger.debug "Enabling cron locking at pid #{Process.pid.to_s}" @scheduler.every(settings[:lock_delay] || "10s", :overlap => false) do c = Class.new.extend(Ocular::DSL::Etcd) @cron_enabled = c.ttl_lock("cron_input", ttl:20) end end end |
Instance Attribute Details
#cron_enabled ⇒ Object (readonly)
Returns the value of attribute cron_enabled.
29 30 31 |
# File 'lib/ocular/inputs/cron_input.rb', line 29 def cron_enabled @cron_enabled end |
#routes ⇒ Object (readonly)
Returns the value of attribute routes.
27 28 29 |
# File 'lib/ocular/inputs/cron_input.rb', line 27 def routes @routes end |
#scheduler ⇒ Object (readonly)
Returns the value of attribute scheduler.
28 29 30 |
# File 'lib/ocular/inputs/cron_input.rb', line 28 def scheduler @scheduler end |
Instance Method Details
#disable ⇒ Object
65 66 67 |
# File 'lib/ocular/inputs/cron_input.rb', line 65 def disable() @cron_enabled = false end |
#enable ⇒ Object
69 70 71 |
# File 'lib/ocular/inputs/cron_input.rb', line 69 def enable() @cron_enabled = true end |
#start ⇒ Object
57 58 59 |
# File 'lib/ocular/inputs/cron_input.rb', line 57 def start() end |
#stop ⇒ Object
61 62 63 |
# File 'lib/ocular/inputs/cron_input.rb', line 61 def stop() @scheduler.shutdown end |