forked from getlago/lago-api
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.rb
44 lines (33 loc) · 1.08 KB
/
clock.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
# frozen_string_literal: true
require 'clockwork'
require './config/boot'
require './config/environment'
module Clockwork
handler do |job, time|
puts "Running #{job} at #{time}"
end
error_handler do |error|
Rails.logger.error(e.message)
Rails.logger.error(e.backtrace.join("\n"))
Sentry.capture_exception(error)
end
# NOTE: All clocks run every hour to take customer timezones into account
every(1.hour, 'schedule:activate_subscriptions', at: '**:30') do
Clock::ActivateSubscriptionsJob.perform_later
end
every(1.hour, 'schedule:bill_customers', at: '*:10') do
Clock::SubscriptionsBillerJob.perform_later
end
every(1.hour, 'schedule:finalize_invoices', at: '*:20') do
Clock::FinalizeInvoicesJob.perform_later
end
every(1.hour, 'schedule:terminate_coupons', at: '*:30') do
Clock::TerminateCouponsJob.perform_later
end
every(1.hour, 'schedule:terminate_wallets', at: '*:45') do
Clock::TerminateWalletsJob.perform_later
end
every(1.day, 'schedule:clean_webhooks', at: '01:00') do
Clock::WebhooksCleanupJob.perform_later
end
end