Class: InboxSync::Runner
- Inherits:
-
Object
- Object
- InboxSync::Runner
- Defined in:
- lib/inbox-sync/runner.rb
Instance Attribute Summary collapse
-
#interval ⇒ Object
readonly
Returns the value of attribute interval.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
-
#syncs ⇒ Object
readonly
Returns the value of attribute syncs.
Instance Method Summary collapse
-
#initialize(*args) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(*args) ⇒ Runner
Returns a new instance of Runner.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
# File 'lib/inbox-sync/runner.rb', line 9 def initialize(*args) opts, syncs = [ args.last.kind_of?(Hash) ? args.pop : {}, args.flatten ] @syncs = syncs || [] @interval = opts[:interval].kind_of?(Fixnum) ? opts[:interval] : -1 @logger = opts[:logger] || Logger.new(STDOUT) @shutdown = false @running_syncs_thread = nil Signal.trap('SIGINT', lambda{ self.stop }) Signal.trap('SIGQUIT', lambda{ self.stop }) end |
Instance Attribute Details
#interval ⇒ Object (readonly)
Returns the value of attribute interval.
7 8 9 |
# File 'lib/inbox-sync/runner.rb', line 7 def interval @interval end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
7 8 9 |
# File 'lib/inbox-sync/runner.rb', line 7 def logger @logger end |
#syncs ⇒ Object (readonly)
Returns the value of attribute syncs.
7 8 9 |
# File 'lib/inbox-sync/runner.rb', line 7 def syncs @syncs end |
Instance Method Details
#start ⇒ Object
25 26 27 28 29 30 31 32 |
# File 'lib/inbox-sync/runner.rb', line 25 def start startup loop do break if @shutdown loop_run end shutdown end |
#stop ⇒ Object
34 35 36 37 |
# File 'lib/inbox-sync/runner.rb', line 34 def stop main_log "Stop signal - waiting for any running syncs to finish." @shutdown = true end |