12: def initialize(args)
13: @options = {
14: :quiet => true,
15: :pid_dir => "#{Rails.root}/tmp/pids"
16: }
17:
18: @worker_count = 1
19: @monitor = false
20:
21: opts = OptionParser.new do |opts|
22: opts.banner = "Usage: #{File.basename($0)} [options] start|stop|restart|run"
23:
24: opts.on('-h', '--help', 'Show this message') do
25: puts opts
26: exit 1
27: end
28: opts.on('-e', '--environment=NAME', 'Specifies the environment to run this delayed jobs under (test/development/production).') do |e|
29: 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"
30: end
31: opts.on('--min-priority N', 'Minimum priority of jobs to run.') do |n|
32: @options[:min_priority] = n
33: end
34: opts.on('--max-priority N', 'Maximum priority of jobs to run.') do |n|
35: @options[:max_priority] = n
36: end
37: opts.on('-n', '--number_of_workers=workers', "Number of unique workers to spawn") do |worker_count|
38: @worker_count = worker_count.to_i rescue 1
39: end
40: opts.on('--pid-dir=DIR', 'Specifies an alternate directory in which to store the process ids.') do |dir|
41: @options[:pid_dir] = dir
42: end
43: opts.on('-i', '--identifier=n', 'A numeric identifier for the worker.') do |n|
44: @options[:identifier] = n
45: end
46: opts.on('-m', '--monitor', 'Start monitor process.') do
47: @monitor = true
48: end
49: opts.on('--sleep-delay N', "Amount of time to sleep when no jobs are found") do |n|
50: @options[:sleep_delay] = n
51: end
52: opts.on('-p', '--prefix NAME', "String to be prefixed to worker process names") do |prefix|
53: @options[:prefix] = prefix
54: end
55: opts.on('--queues=queues', "Specify which queue DJ must look up for jobs") do |queues|
56: @options[:queues] = queues.split(',')
57: end
58: opts.on('--queue=queue', "Specify which queue DJ must look up for jobs") do |queue|
59: @options[:queues] = queue.split(',')
60: end
61: end
62: @args = opts.parse!(args)
63: end