Skip to content

Instantly share code, notes, and snippets.

@seigel
Created November 4, 2011 05:32
Show Gist options
  • Save seigel/1338725 to your computer and use it in GitHub Desktop.
Save seigel/1338725 to your computer and use it in GitHub Desktop.
Resque on Cloudfoundry
# 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, {})
...
@millisami
Copy link

Thanks, I'll check it out.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment