Class: ResqueAdmin::Scheduler::Cli
- Inherits:
-
Object
- Object
- ResqueAdmin::Scheduler::Cli
- Defined in:
- lib/resque/scheduler/cli.rb,
lib/resque/scheduler_admin/cli.rb,
lib/resque_admin/scheduler/cli.rb
Constant Summary collapse
- BANNER =
<<-EOF.gsub(/ {6}/, '') Usage: resque_admin-scheduler [options] Runs a resque_admin scheduler process directly (rather than via rake). EOF
- OPTIONS =
[ { args: ['-n', '--app-name [APP_NAME]', 'Application name for procline'], callback: ->() { ->(n) { [:app_name] = n } } }, { args: ['-B', '--background', 'Run in the background [BACKGROUND]'], callback: ->() { ->(b) { [:background] = b } } }, { args: ['-D', '--dynamic-schedule', 'Enable dynamic scheduling [DYNAMIC_SCHEDULE]'], callback: ->() { ->(d) { [:dynamic] = d } } }, { args: ['-E', '--environment [RAILS_ENV]', 'Environment name'], callback: ->() { ->(e) { [:env] = e } } }, { args: ['-I', '--initializer-path [INITIALIZER_PATH]', 'Path to optional initializer ruby file'], callback: ->() { ->(i) { [:initializer_path] = i } } }, { args: ['-i', '--interval [RESQUE_SCHEDULER_INTERVAL]', 'Interval for checking if a scheduled job must run'], callback: ->() { ->(i) { [:poll_sleep_amount] = i } } }, { args: ['-l', '--logfile [LOGFILE]', 'Log file name'], callback: ->() { ->(l) { [:logfile] = l } } }, { args: ['-F', '--logformat [LOGFORMAT]', 'Log output format'], callback: ->() { ->(f) { [:logformat] = f } } }, { args: ['-P', '--pidfile [PIDFILE]', 'PID file name'], callback: ->() { ->(p) { [:pidfile] = p } } }, { args: ['-q', '--quiet', 'Run with minimal output [QUIET]'], callback: ->() { ->(q) { [:quiet] = q } } }, { args: ['-v', '--verbose', 'Run with verbose output [VERBOSE]'], callback: ->() { ->(v) { [:verbose] = v } } } ].freeze
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(argv = ARGV, env = ENV) ⇒ Cli
constructor
A new instance of Cli.
- #parse_options ⇒ Object
- #pre_run ⇒ Object
- #pre_setup ⇒ Object
- #run! ⇒ Object
- #run_forever ⇒ Object
- #setup_env ⇒ Object
Constructor Details
#initialize(argv = ARGV, env = ENV) ⇒ Cli
Returns a new instance of Cli.
83 84 85 86 |
# File 'lib/resque/scheduler/cli.rb', line 83 def initialize(argv = ARGV, env = ENV) @argv = argv @env = env end |
Class Method Details
.run!(argv = ARGV, env = ENV) ⇒ Object
79 80 81 |
# File 'lib/resque/scheduler/cli.rb', line 79 def self.run!(argv = ARGV, env = ENV) new(argv, env).run! end |
Instance Method Details
#parse_options ⇒ Object
99 100 101 |
# File 'lib/resque/scheduler/cli.rb', line 99 def option_parser.parse!(argv.dup) end |
#pre_run ⇒ Object
93 94 95 96 97 |
# File 'lib/resque/scheduler/cli.rb', line 93 def pre_run pre_setup setup_env end |
#pre_setup ⇒ Object
103 104 105 106 107 108 109 |
# File 'lib/resque/scheduler/cli.rb', line 103 def pre_setup if [:initializer_path] load [:initializer_path].to_s.strip else false end end |
#run! ⇒ Object
88 89 90 91 |
# File 'lib/resque/scheduler/cli.rb', line 88 def run! pre_run run_forever end |
#run_forever ⇒ Object
116 117 118 |
# File 'lib/resque/scheduler/cli.rb', line 116 def run_forever ResqueAdmin::Scheduler.run end |
#setup_env ⇒ Object
111 112 113 114 |
# File 'lib/resque/scheduler/cli.rb', line 111 def setup_env require_relative 'env' runtime_env.setup end |