9: def initialize(args)
10: @files_to_reopen = []
11: @options = {
12: :quiet => true,
13: :pid_dir => "#{RAILS_ROOT}/tmp/pids"
14: }
15:
16: @worker_count = 1
17: @monitor = false
18:
19: opts = OptionParser.new do |opts|
20: opts.banner = "Usage: #{File.basename($0)} [options] start|stop|restart|run"
21:
22: opts.on('-h', '--help', 'Show this message') do
23: puts opts
24: exit 1
25: end
26: opts.on('-e', '--environment=NAME', 'Specifies the environment to run this delayed jobs under (test/development/production).') do |e|
27: STDERR.puts "The -e/--environment option has been deprecated and has no effect. Use RAILS_ENV and see http://github.com/collectiveidea/delayed_job/issues/#issue/7"
28: end
29: opts.on('--min-priority N', 'Minimum priority of jobs to run.') do |n|
30: @options[:min_priority] = n
31: end
32: opts.on('--max-priority N', 'Maximum priority of jobs to run.') do |n|
33: @options[:max_priority] = n
34: end
35: opts.on('-n', '--number_of_workers=workers', "Number of unique workers to spawn") do |worker_count|
36: @worker_count = worker_count.to_i rescue 1
37: end
38: opts.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|
39: @options[:pid_dir] = dir
40: end
41: opts.on('-i', '--identifier=n', 'A numeric identifier for the worker.') do |n|
42: @options[:identifier] = n
43: end
44: opts.on('-m', '--monitor', 'Start monitor process.') do
45: @monitor = true
46: end
47: opts.on('--sleep-delay N', "Amount of time to sleep when no jobs are found") do |n|
48: @options[:sleep_delay] = n
49: end
50: end
51: @args = opts.parse!(args)
52: end