Created
November 4, 2011 05:32
-
-
Save seigel/1338725 to your computer and use it in GitHub Desktop.
Resque on Cloudfoundry
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
# shell for the real worker in the other project | |
class EmailSentCount | |
@queue = :high | |
end |
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
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 |
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
... | |
require File.join(File.dirname(__FILE__), '../../lib/email_sent_count') # shell job for update profile | |
... |
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
... | |
Resque.enqueue(EmailSentCount, {}) | |
... |
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.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.