-
-
Save seigel/1338725 to your computer and use it in GitHub Desktop.
# shell for the real worker in the other project | |
class EmailSentCount | |
@queue = :high | |
end |
require 'mining' | |
if ENV['VCAP_SERVICES'].nil? | |
if Rails.env == 'development' | |
Mining.set_redis(Redis.new) | |
Resque.redis = Redis.new | |
Mining.redis.select(4) | |
end | |
else | |
vcap_services = JSON.parse(ENV['VCAP_SERVICES']) | |
redis = vcap_services.detect { |k,v| k =~ /redis/ }.last.first | |
redis_host = redis["credentials"]["hostname"] | |
redis_port = redis["credentials"]["port"] | |
redis_password = redis["credentials"]["password"] | |
Mining.set_redis(Redis.new( :host => redis_host, :port => redis_port, :password => redis_password )) | |
Resque.redis = Redis.new( :host => redis_host, :port => redis_port, :password => redis_password) | |
Mining.redis.select(4) | |
end |
... | |
require File.join(File.dirname(__FILE__), '../../lib/email_sent_count') # shell job for update profile | |
... |
... | |
Resque.enqueue(EmailSentCount, {}) | |
... |
This is all the Rails side of the application. I have a resque application running which attaches to the same redis server and then runs jobs when it sees them. This gives some nice decoupling between the rails application and the workers.
Is there any repo/gist on running the resque app separately on the CloudFoundry?
Last time I tried running in the same rails app as threaded process in config/initializer
, but couldn't get any success with it.
So, it would be great to see on how to run the resque app separately since CF doesn't provide any rake tasks to run on its platform. I really like to see your approach on how you're running resque app separately!
I'll post a skeleton here shortly :)
Do please! Thanks
Take a look here and play around with it...I left some example jobs in etc..you'll have to change or remove some settings for your example. This one uses redis and mongodb :)
https://github.com/seigel/rescue_worker_cloudfoundry_example
Good luck
Thanks, I'll check it out.
Is this in separate apps or a single app?
Can you plz explain how the setup is done?