public
Last active

Example dante daemon with beanstalkd

  • Download Gist
queue_daemon
Ruby
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
#!/usr/bin/env ruby
 
require 'bundler/setup'
require 'dante'
require 'beaneater'
 
Dante.run('mailer') do |opts|
# Connect to beanstalkd on default ports
beanstalk = Beaneater::Pool.new ['localhost:11300']
 
beanstalk.jobs.register(options.queue) do |job|
# This is useful for integration testing or if you wish to gracefully stop processing before killing the daemon
raise Beaneater::AbortProcessingError if job.body == "no_more_beans"
# process the job for example
ExampleMailer.send_test(job).deliver
end
beanstalk.jobs.process!
end

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.