Class: Resque::Scheduler::Cli
- Inherits:
-
Object
- Object
- Resque::Scheduler::Cli
- Defined in:
- lib/resque/scheduler/cli.rb
Constant Summary collapse
- BANNER =
<<-EOF.gsub(/ {6}/, '') Usage: resque-scheduler [options] Runs a resque 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.
84 85 86 87 |
# File 'lib/resque/scheduler/cli.rb', line 84 def initialize(argv = ARGV, env = ENV) @argv = argv @env = env end |
Class Method Details
.run!(argv = ARGV, env = ENV) ⇒ Object
80 81 82 |
# File 'lib/resque/scheduler/cli.rb', line 80 def self.run!(argv = ARGV, env = ENV) new(argv, env).run! end |
Instance Method Details
#parse_options ⇒ Object
100 101 102 |
# File 'lib/resque/scheduler/cli.rb', line 100 def option_parser.parse!(argv.dup) end |
#pre_run ⇒ Object
94 95 96 97 98 |
# File 'lib/resque/scheduler/cli.rb', line 94 def pre_run pre_setup setup_env end |
#pre_setup ⇒ Object
104 105 106 107 108 109 110 |
# File 'lib/resque/scheduler/cli.rb', line 104 def pre_setup if [:initializer_path] load [:initializer_path].to_s.strip else false end end |
#run! ⇒ Object
89 90 91 92 |
# File 'lib/resque/scheduler/cli.rb', line 89 def run! pre_run run_forever end |
#run_forever ⇒ Object
117 118 119 |
# File 'lib/resque/scheduler/cli.rb', line 117 def run_forever Resque::Scheduler.run end |
#setup_env ⇒ Object
112 113 114 115 |
# File 'lib/resque/scheduler/cli.rb', line 112 def setup_env require_relative 'env' runtime_env.setup end |