Running scheduled jobs from Rails app

I’m moving my rails app from Digital Ocean to Fly, and I have a few background jobs that I need to run:

  1. hourly Firebase certificate fetch from Firebase’s servers
  2. a scraper that gets some data from the web

they’re currently set up as rake tasks, so app.json contains:

"cron": [
    {
      "command": "rake 'firebase:certificates:force_request'",
      "schedule": "@hourly"
    },
...
]

It doesn’t seem that fly is running these?

As an addendum, it doesn’t seem that Fly is running postdeploy.sh when I deploy?

1 Like

I think this app.json format might be specific to Digital Ocean, it’s not something our system knows what to do with.

We don’t have a cron feature yet. We actually use sidekiq to schedule jobs like that, but some people just run a tiny VM with cron in it too.

What does postdeploy.sh do?

sidekiq-scheduler is a good option if you’re using Sidekiq. It’s better than cron in many ways - not least because you can monitor jobs in the Sidekiq web UI.

DO has predeploy and postdeploy job types. Predeploy is equivalent to the Fly release command in fly.toml. This will run after a successful build, but before the deployment is released.

Fly has no equivalent to postdeploy, but most apps are OK with predeploy.

Hi @jsierles ! I use sidekiq-scheduler but when I try to deploy with:
worker = "bundle exec sidekiq -C config/sidekiq.yml"

It throws to me that ‘C’ is not valid. How I deploy a sidekiq with scheduled jobs?

When i add this to fly.toml,
scheduler = "IS_SCHEDULER=true bundle exec sidekiq"
throw error too. System did’t know flag IS_SCHEDULER. I would like process ‘scheduler’ run on one machine.

scheduler = "bundle exec sidekiq -C config/scheduler.yml"
in [processes] can working now. It’s great, so scheduler can run only one machine, other worker process can scale freely.