Skip to content

Instantly share code, notes, and snippets.

@lefty313
Created April 11, 2017 11:51
Show Gist options
  • Save lefty313/ac57df1dfd97133c9672c8f9f0e77540 to your computer and use it in GitHub Desktop.
Save lefty313/ac57df1dfd97133c9672c8f9f0e77540 to your computer and use it in GitHub Desktop.
require File.expand_path("config/environment")
Zhong.redis = Redis.new(...)
Zhong.schedule do
error_handler do |e, job|
Airbrake.notify(e, params: {job: job.to_s, job_id: job.id })
end
category "Performance Reminder" do
every 1.week, "weekly_perfomance", at: ["mon 12:01"] do
SchedulePerformanceRecapWorker.perform_async
end
end
category "Syncing" do
every 1.minute, "summoners of premium users" do
AutosyncPremiumUsersWorker.perform_async
end
every 1.minute, "summoners of regular users" do
ScheduleSummonersSyncWorker.perform_async
end
end
category "Misc" do
every 1.week, "clean guest users", at: ["wed 0:01"] do
GuestUsersCleanupWorker.perform_async
end
every 15.seconds, "check access matches" do
min5 = $redis.zcount("matches:accessed", 5.minutes.ago.to_i, "+inf")
min25 = $redis.zcount("matches:accessed", 25.minutes.ago.to_i, "+inf")
hour1 = $redis.zcount("matches:accessed", 1.hour.ago.to_i, "+inf")
hour24 = $redis.zcount("matches:accessed", 24.hour.ago.to_i, "+inf")
week = $redis.zcount("matches:accessed", 7.days.ago.to_i, "+inf")
total = $redis.zcount("matches:accessed", "-inf", "+inf")
NewRelic::Agent.record_metric("Database/MatchAccess/Last5Min", min5)
NewRelic::Agent.record_metric("Database/MatchAccess/Last25Min", min25)
NewRelic::Agent.record_metric("Database/MatchAccess/LastHour", hour1)
NewRelic::Agent.record_metric("Database/MatchAccess/LastDay", hour24)
NewRelic::Agent.record_metric("Database/MatchAccess/LastWeek", week)
NewRelic::Agent.record_metric("Database/MatchAccess/Alltime", total)
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment