mirror of
https://github.com/discourse/discourse.git
synced 2025-02-25 18:55:32 -06:00
Basic Heroku integration
This commit is contained in:
@@ -4,8 +4,9 @@
|
||||
class DiscourseRedis
|
||||
|
||||
def initialize
|
||||
@config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
|
||||
@config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
redis_opts = {:host => @config['host'], :port => @config['port'], :db => @config['db']}
|
||||
redis_opts[:password] = @config['password'] if @config['password']
|
||||
@redis = Redis.new(redis_opts)
|
||||
end
|
||||
|
||||
@@ -36,14 +37,14 @@ class DiscourseRedis
|
||||
end
|
||||
|
||||
def self.new_redis_store
|
||||
redis_config = YAML::load(File.open("#{Rails.root}/config/redis.yml"))[Rails.env]
|
||||
redis_store = ActiveSupport::Cache::RedisStore.new "redis://#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"
|
||||
redis_config = YAML.load(ERB.new(File.new("#{Rails.root}/config/redis.yml").read).result)[Rails.env]
|
||||
redis_store = ActiveSupport::Cache::RedisStore.new "redis://#{(':' + redis_config['password'] + '@') if redis_config['password']}#{redis_config['host']}:#{redis_config['port']}/#{redis_config['cache_db']}"
|
||||
redis_store.options[:namespace] = -> { DiscourseRedis.namespace }
|
||||
redis_store
|
||||
end
|
||||
|
||||
def url
|
||||
"redis://#{@config['host']}:#{@config['port']}/#{@config['db']}"
|
||||
"redis://#{(':' + @config['password'] + '@') if @config['password']}#{@config['host']}:#{@config['port']}/#{@config['db']}"
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
36
lib/tasks/scheduler.rake
Normal file
36
lib/tasks/scheduler.rake
Normal file
@@ -0,0 +1,36 @@
|
||||
desc "This task is called by the Heroku scheduler add-on"
|
||||
|
||||
# Every day at 6am
|
||||
task :enqueue_digest_emails => :environment do
|
||||
Jobs::EnqueueDigestEmails.new.execute(nil)
|
||||
end
|
||||
|
||||
# Every day at 4am
|
||||
task :category_stats => :environment do
|
||||
Jobs::CategoryStats.new.execute(nil)
|
||||
end
|
||||
|
||||
# Every 10 minutes
|
||||
task :calculate_avg_time => :environment do
|
||||
Jobs::CalculateAvgTime.new.execute(nil)
|
||||
end
|
||||
|
||||
# Every 10 minutes
|
||||
task :feature_topics => :environment do
|
||||
Jobs::FeatureTopics.new.execute(nil)
|
||||
end
|
||||
|
||||
# Every 10 minutes
|
||||
task :calculate_score => :environment do
|
||||
Jobs::CalculateScore.new.execute(nil)
|
||||
end
|
||||
|
||||
# Every 10 minutes
|
||||
task :calculate_view_counts => :environment do
|
||||
Jobs::CalculateViewCounts.new.execute(nil)
|
||||
end
|
||||
|
||||
# Every day
|
||||
task :version_check => :environment do
|
||||
Jobs::VersionCheck.new.execute(nil)
|
||||
end
|
||||
Reference in New Issue
Block a user