Skip to content

Instantly share code, notes, and snippets.

@maccman
Created April 2, 2009 10:31
Show Gist options
  • Select an option

  • Save maccman/89127 to your computer and use it in GitHub Desktop.

Select an option

Save maccman/89127 to your computer and use it in GitHub Desktop.
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/environment'
def start_processor(queue)
puts "Starting #{queue} processor..."
klass = queue.to_s.camelize.constantize
klass.start!(true)
end
def stop_processor(queue)
puts "Stopping #{queue} processor..."
klass = queue.to_s.camelize.constantize
klass.stop!
end
def restart_processor(queue)
stop_processor(queue)
start_processor(queue)
end
case ARGV[0]
when 'start'
if queue = ARGV[1]
start_processor(queue)
else
Processor.all.each {|queue|
start_processor(queue)
}
end
when 'stop'
if queue = ARGV[1]
stop_processor(queue)
else
Processor.all.each {|queue|
stop_processor(queue)
}
end
when 'restart'
if queue = ARGV[1]
restart_processor(queue)
else
Processor.all.each {|queue|
restart_processor(queue)
}
end
else
puts "Usage: processors {start|stop|restart} [queue_name]"
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment