bensheldon / good_job

Multithreaded, Postgres-based, Active Job backend for Ruby on Rails.
https://goodjob-demo.herokuapp.com/
MIT License
2.7k stars 201 forks source link

Cron Schedule not visible in dashboard #496

Closed 34code closed 2 years ago

34code commented 2 years ago

I followed the instructions to add cron schedule as follows in application.rb

config.active_job.queue_adapter = :good_job
    config.good_job.enable_cron = true

    config.good_job.cron = {
      walmart_etl_arts_crafts: {
        cron: "30 19 * * *", # every day at 7:30p
        class: "Etl::Walmart::ArtsCrafts",
        args: [etl_dir: "arts_crafts", ftp_path: "/etl", temp_path: "/tmp", filename: "Walmart-arts-crafts-sewing_IR.txt.gz", category: "Arts & Crafts"]
      }
    }

Screen Shot 2022-01-25 at 2 50 27 PM

but the dashboard doesn't seem to reflect this job..

bensheldon commented 2 years ago

@34code that configuration looks correct. I tried loading it locally and it looks like it's appearing correctly for me.

Hmm. If this is in development, have you restarted your webserver since adding the configuration?

Screen Shot 2022-01-25 at 3 08 29 PM

34code commented 2 years ago

wow, thanks for the quick response. Yes I've tried restarting the rails server in dev and also restarted good_job with

good_job start --enable-cron=true

Not sure if i should be putting the config in application.rb or development.rb ..

34code commented 2 years ago

I'm also using Ruby 3.1.0 and Rails 7.0.1

bensheldon commented 2 years ago

You raised the issue at a good time; at least for the moment :-)

What's displayed on the GoodJob Dashboard comes down to whatever Rails.application.configuration.good_job.cron's hash value is on the webserver that's rendering the dashboard.

You could try opening a rails console and seeing what the value is.

34code commented 2 years ago

hmm.. seems like mine is returning way too much in rails console.. its over 10k lines

I'll try with a fresh rails install becasue this was a hacky upgrade from rails 6.1

bensheldon commented 2 years ago

@34code any progress? That's really weird that the result would be so long. The configuration value should be exactly what you configured in your application.rb.

34code commented 2 years ago

I can confirm that its working in rails 7 .. seems like i have some config issues in my rails 6.1.0 project. Will need to gradually migrate to rails 7 anyway so this was a good forcing function.

34code commented 2 years ago

hmm.. after I migrated some more of my code over to the new rails 7 project, I'm back in this bind..

Running Rails.application.configuration.good_job.cron yields NoMethodError: undefined methodconfiguration' for #<Botflip7::Application...` in console

I was working well until I added in sassc and some other frontend-related gems :(

bensheldon commented 2 years ago

Oops, sorry the prefix is Rails.application.config / Rails.configuration. e.g. Rails.application.config.good_job.cron

34code commented 2 years ago

hmm.. that seems to render the hash properly. I'm stumped.

{:walmart_etl_arts_crafts=>
  {:cron=>"30 19 * * *",
   :class=>"Etl::Walmart::ArtsCrafts",
   :args=>
    [{:etl_dir=>"arts_crafts",
      :ftp_path=>"/Users/sambit/Documents/RAILS/Staging/etl",
      :temp_path=>"/tmp",
      :filename=>"Walmart-arts-crafts-sewing_IR.txt.gz",
      :category=>"Arts & Crafts"}]}}
bensheldon commented 2 years ago

Hmmm. Here's my calendar if you wanted to find a time together to look at the code. I'm really curious and eager to help: https://calendly.com/bensheldon/office-hours

34code commented 2 years ago

Thanks so much for the offer, @bensheldon ! I swear I did nothing different (except maybe moving the cron task from development.rb to application.rb), but now its showing up :)

Would still love to chat about how I can help with this project however I can be of help.. and some scale related questions (not that my project will run into scale issues anytime soon) out of curiosity.