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, {}) | |
... |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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