Class: ShellElf::Runner
- Inherits:
-
Object
- Object
- ShellElf::Runner
- Defined in:
- lib/shell_elf/runner.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options) ⇒ Runner
constructor
A new instance of Runner.
- #interrupted! ⇒ Object
- #run ⇒ Object
Constructor Details
#initialize(options) ⇒ Runner
Returns a new instance of Runner.
18 19 20 |
# File 'lib/shell_elf/runner.rb', line 18 def initialize() @options = end |
Class Method Details
.run(options) ⇒ Object
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/shell_elf/runner.rb', line 6 def run() runner = new() signal_handler = proc do ShellElf.logger.info("Received signal - gracefully exiting...") exit if runner.interrupted! end trap('INT', &signal_handler) trap('TERM', &signal_handler) runner.run end |
Instance Method Details
#interrupted! ⇒ Object
33 34 35 36 37 38 39 40 41 42 |
# File 'lib/shell_elf/runner.rb', line 33 def interrupted! # return true unless @current if @current && @current[:options] && @current[:options][:on_interrupt] == :requeue starling.set(@options[:queue], @current) true else @interrupted = true false end end |
#run ⇒ Object
22 23 24 25 26 27 28 29 30 31 |
# File 'lib/shell_elf/runner.rb', line 22 def run until @interrupted if starling && @current = starling.fetch(@options[:queue]) ShellElf.logger.debug("RUNNER: #{@current.inspect}") ShellElf::Batch.execute(@current) else sleep Starling::WAIT_TIME end end end |