Skip to content
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

Rake Task Support in Recurring Jobs #379

Open
kaka-ruto opened this issue Oct 9, 2024 · 1 comment
Open

Rake Task Support in Recurring Jobs #379

kaka-ruto opened this issue Oct 9, 2024 · 1 comment

Comments

@kaka-ruto
Copy link

kaka-ruto commented Oct 9, 2024

Would you be open to supporting rake tasks in recurring jobs?

Something like this

production:
  generate_sitemap:
    rake: sitemap:refresh
    flags:
      s: true
      verbose: true
    schedule: every day at 3am

  custom_rake_task:
    rake: my:custom:task
    args: ['arg1', 'arg2']
    flags:
      environment: production
    schedule: every hour

I can give it a jab.

@kylekeesling
Copy link

I like this idea. To solve this for now I created a generic Job that allows me to pass rake tasks in as the argument:

# frozen_string_literal: true

class RakeTaskJob < ApplicationJob
  queue_as :default

  def perform(command)
    require "rake"

    Rake.application.init
    Rake.application.load_rakefile

    Rake::Task[command].invoke
  end
end

Then I can just do this in recurring.yml:

  monday_job:
    class: RakeTaskJob
    args: "scheduled_tasks:monday_jobs"
    schedule: every Monday at 7am UTC

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants