Class: Jiggler::CLI
Constant Summary collapse
- CONTEXT_SWITCHER_THRESHOLD =
0.5
- NUMERIC_OPTIONS =
%i[ concurrency client_concurrency timeout in_process_interval poll_interval stats_interval max_dead_jobs dead_timeout ].freeze
- SIGNAL_HANDLERS =
{ :INT => ->(cli) { cli.logger.fatal('Received INT, shutting down') cli.stop }, :TERM => ->(cli) { cli.logger.fatal('Received TERM, shutting down') cli.stop }, :TSTP => ->(cli) { cli.logger.info('Received TSTP, no longer accepting new work') cli.suspend } }
- UNHANDLED_SIGNAL_HANDLER =
->(cli) { cli.logger.info('No signal handler registered, ignoring') }
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#environment ⇒ Object
readonly
Returns the value of attribute environment.
-
#logger ⇒ Object
readonly
Returns the value of attribute logger.
Instance Method Summary collapse
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
27 28 29 |
# File 'lib/jiggler/cli.rb', line 27 def config @config end |
#environment ⇒ Object (readonly)
Returns the value of attribute environment.
27 28 29 |
# File 'lib/jiggler/cli.rb', line 27 def environment @environment end |
#logger ⇒ Object (readonly)
Returns the value of attribute logger.
27 28 29 |
# File 'lib/jiggler/cli.rb', line 27 def logger @logger end |
Instance Method Details
#parse_and_init(args = ARGV.dup) ⇒ Object
47 48 49 50 51 52 53 54 |
# File 'lib/jiggler/cli.rb', line 47 def parse_and_init(args = ARGV.dup) @config ||= Jiggler.config (args) initialize_logger validate! load_app end |
#start ⇒ Object
56 57 58 59 60 61 62 63 64 65 66 67 68 69 |
# File 'lib/jiggler/cli.rb', line 56 def start return unless ping_redis @cond = Async::Condition.new Async do setup_signal_handlers patch_scheduler @launcher = Launcher.new(config) @launcher.start Async do @cond.wait end end @switcher&.exit end |
#stop ⇒ Object
71 72 73 74 75 |
# File 'lib/jiggler/cli.rb', line 71 def stop @launcher.stop logger.info('Jiggler is stopped, bye!') @cond.signal end |
#suspend ⇒ Object
77 78 79 80 |
# File 'lib/jiggler/cli.rb', line 77 def suspend @launcher.suspend logger.info('Jiggler is suspended') end |