Skip to content

Commit

Permalink
Add recurring task
Browse files Browse the repository at this point in the history
  • Loading branch information
vincent-pochet committed Nov 26, 2024
1 parent 6431d57 commit 46ae840
Show file tree
Hide file tree
Showing 5 changed files with 27 additions and 17 deletions.
10 changes: 5 additions & 5 deletions clock.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,11 @@ module Clockwork

# NOTE: All clocks run every hour to take customer timezones into account

every(5.minutes, 'schedule:activate_subscriptions') do
Clock::ActivateSubscriptionsJob
.set(sentry: {"slug" => 'lago_activate_subscriptions', "cron" => '*/5 * * * *'})
.perform_later
end
# every(5.minutes, 'schedule:activate_subscriptions') do
# Clock::ActivateSubscriptionsJob
# .set(sentry: {"slug" => 'lago_activate_subscriptions', "cron" => '*/5 * * * *'})
# .perform_later
# end

every(5.minutes, 'schedule:refresh_draft_invoices') do
Clock::RefreshDraftInvoicesJob
Expand Down
3 changes: 3 additions & 0 deletions config/queue.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,8 @@ development:
test:
<<: *default

staging:
<<: *default

production:
<<: *default
27 changes: 17 additions & 10 deletions config/recurring.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
# production:
# periodic_cleanup:
# class: CleanSoftDeletedRecordsJob
# queue: background
# args: [ 1000, { batch_size: 500 } ]
# schedule: every hour
# periodic_command:
# command: "SoftDeletedRecord.due.delete_all"
# priority: 2
# schedule: at 5am every day
default: &default
activate_subscriptions:
class: Clock::ActivateSubscriptionsJob
queue: clock
schedule: every 5 minutes

development:
<<: *default

test:
<<: *default

staging:
<<: *default

production:
<<: *default
2 changes: 1 addition & 1 deletion scripts/start.worker.dev.sh
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#!/bin/bash

bundle install
bin/jobs -c config/queue.yml
bin/jobs -c config/queue.yml --recurring-schedule-file=config/recurring.yml
2 changes: 1 addition & 1 deletion scripts/start.worker.sh
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
#!/bin/bash

bin/jobs -c config/queue.yml
bin/jobs -c config/queue.yml --recurring_schedule_file=config/recurring.yml

0 comments on commit 46ae840

Please sign in to comment.