Last active
December 19, 2015 04:29
-
-
Save bangline/5897674 to your computer and use it in GitHub Desktop.
Example dante daemon with beanstalkd
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment