Class: RCelery::Daemon
- Inherits:
-
Object
- Object
- RCelery::Daemon
- Defined in:
- lib/rcelery/daemon.rb
Instance Method Summary collapse
-
#initialize(args) ⇒ Daemon
constructor
A new instance of Daemon.
- #run ⇒ Object
- #trap_signals ⇒ Object
Constructor Details
#initialize(args) ⇒ Daemon
Returns a new instance of Daemon.
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 |
# File 'lib/rcelery/daemon.rb', line 6 def initialize(args) @config = RCelery::Configuration.new opts = OptionParser.new do |opt| opt.on('-n', '--hostname HOSTNAME', 'Hostname of the AMQP broker') do |host| @config.host = host end opt.on('-p', '--port PORT', 'Port of the AMQP broker') do |port| @config.port = port end opt.on('-v', '--vhost VHOST', 'Vhost of the AMQP broker') do |vhost| @config.vhost = vhost end opt.on('-u', '--username USERNAME', 'Username to use during authentication with the AMQP broker') do |username| @config.username = username end opt.on('-w', '--password PASSWORD', 'Password to use during authentication with the AMQP broker') do |password| @config.password = password end opt.on('-a', '--application APPLICATION', 'Name of the application') do |application| @config.application = application end opt.on('-t', '--tasks lib1,lib2,...', Array, 'List of libraries to require that contain task definitions') do |requires| requires.each do |lib| require lib end end opt.on('-r', '--rails', 'Require \'config/environment\' to provide the Rails environment') do require 'config/environment' require 'rcelery/rails' RCelery::Rails.initialize ::Rails.logger.auto_flushing = true end opt.on('-W', '--workers NUMBER', 'The number of workers to launch (default 1)') do |num| @config.worker_count = num end opt.on_tail('-h', '--help', 'Show this message') do puts opts exit end end opts.parse!(args) end |