-
-
Notifications
You must be signed in to change notification settings - Fork 785
Replace whenever with sidekiq scheduler #14119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
80a12db
Move database clean from cron to Sidekiq scheduler
mkllnk b61f6ab
Schedule all jobs with Sidekiq
mkllnk 60edcad
Remove whenever config
mkllnk c74624c
Remove unused gem whenever
mkllnk bcecbf9
Require rake dependency to run it within jobs
mkllnk File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,15 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "rake" | ||
|
|
||
| # Executes a rake task | ||
| class RakeJob < ApplicationJob | ||
| def perform(task_string) | ||
| Rails.application.load_tasks if Rake::Task.tasks.empty? | ||
|
|
||
| Rake.application.invoke_task(task_string) | ||
| ensure | ||
| name, _args = Rake.application.parse_task_string(task_string) | ||
| Rake::Task[name].reenable | ||
| end | ||
| end | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,36 @@ | ||
| # Configure sidekiq-scheduler to run jobs. | ||
| # | ||
| # - https://github.com/sidekiq-scheduler/sidekiq-scheduler | ||
| # | ||
| # > Note that every and interval count from when the Sidekiq process (re)starts. | ||
| # > So every: '48h' will never run if the Sidekiq process is restarted daily, | ||
| # > for example. You can do every: ['48h', first_in: '0s'] to make the job run | ||
| # > immediately after a restart, and then have the worker check when it was | ||
| # > last run. | ||
| # | ||
| # Therefore, we use `cron` for jobs that should run at certain times like backups. | ||
| HeartbeatJob: | ||
| every: ["5m", first_in: "0s"] | ||
| SubscriptionPlacementJob: | ||
| every: "5m" | ||
| SubscriptionConfirmJob: | ||
| every: "5m" | ||
| TriggerOrderCyclesToOpenJob: | ||
| every: "5m" | ||
| OrderCycleClosingJob: | ||
| every: "5m" | ||
|
|
||
| backup: | ||
| class: "RakeJob" | ||
| args: ["db2fog:backup"] | ||
| cron: "0 */4 * * *" # every 4 hours | ||
| enabled: <%= ENV.fetch("S3_BACKUPS_BUCKET", false) && true %> | ||
| backup_clean: | ||
| class: "RakeJob" | ||
| args: ["db2fog:clean"] | ||
| cron: "45 2 * * *" # every day at 2:45am | ||
| enabled: <%= ENV.fetch("S3_BACKUPS_BUCKET", false) && true %> | ||
| ofn_clean: | ||
| class: "RakeJob" | ||
| args: ["ofn:data:remove_transient_data"] | ||
| cron: "30 4 1 * *" # every month on the first at 4:30am |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,18 @@ | ||
| # frozen_string_literal: true | ||
|
|
||
| require "tasks/data/remove_transient_data" | ||
|
|
||
| RSpec.describe RakeJob do | ||
| let(:task_string) { "ofn:data:remove_transient_data" } | ||
|
|
||
| it "calls the removal service" do | ||
| expect(RemoveTransientData).to receive(:new).and_call_original | ||
| RakeJob.perform_now(task_string) | ||
| end | ||
|
|
||
| it "can be called several times" do | ||
| expect(RemoveTransientData).to receive(:new).twice.and_call_original | ||
| RakeJob.perform_now(task_string) | ||
| RakeJob.perform_now(task_string) | ||
| end | ||
| end |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice way to wrap up the existing tasks 🥟