Class: SnowmanIO::CLI
- Inherits:
-
Object
- Object
- SnowmanIO::CLI
- Defined in:
- lib/snowman-io/cli.rb
Overview
The command line interface for SnowmanIO.
Instance Attribute Summary collapse
-
#options ⇒ Object
readonly
Returns the value of attribute options.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(options = {}) ⇒ CLI
constructor
A new instance of CLI.
- #run ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ CLI
Returns a new instance of CLI.
13 14 15 |
# File 'lib/snowman-io/cli.rb', line 13 def initialize( = {}) @options = end |
Instance Attribute Details
#options ⇒ Object (readonly)
Returns the value of attribute options.
6 7 8 |
# File 'lib/snowman-io/cli.rb', line 6 def @options end |
Class Method Details
Instance Method Details
#run ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/snowman-io/cli.rb', line 17 def run setup_logger # Self-pipe for deferred signal-handling (http://cr.yp.to/docs/selfpipe.html) self_read, self_write = IO.pipe %w(INT TERM USR1 USR2 TTIN).each do |sig| begin trap sig do self_write.puts(sig) end rescue ArgumentError puts "Signal #{sig} not supported" end end launcher = Launcher.new() begin launcher.start while readable_io = IO.select([self_read]) signal = readable_io.first[0].gets.strip handle_signal(signal) end rescue Interrupt SnowmanIO.logger.info 'Shutting down' launcher.stop exit(0) end end |