-
Notifications
You must be signed in to change notification settings - Fork 332
Running With Sneakers
Dotan J. Nahum edited this page Oct 12, 2013
·
2 revisions
For those of you who want to embed the Sneaker running into their own apps/scripts, this is completely possible. A typical use case would be to create a stand-alone Ruby file that would define a worker and spawn the Sneakers worker cluster.
# my_worker.rb
require 'sneakers'
require 'sneakers/runner'
class MyWorker
include Sneakers::Worker
from_queue 'testing'
def work(msg)
logger.info "hello #{msg}"
end
end
opts = {
# what ever you want
}
Sneakers.configure(opts)
r = Sneakers::Runner.new([MyWorker])
r.run
Now running your script naively like this:
$ ruby my_worker.rb
Will both define the worker and spawn the Sneaker framework to life.