Active Job Rails Cron Job

Sorry for the late response folks, but got everything working. Many thanks for your help!

My final solution ended up using:

  • supercronic by following Recurring scheduled tasks (like cron). I execute my Active Job as a rake task that I had to define.

  • Using Rails Active Job along with the “inline” queue backend to execute the task immediately. I would like to use something like Sidekiq down the line, but I didn’t want to fuss around with it and I wasn’t sure if I would need to run that in yet another process. The inline backend will probably work fine for a while.

  • Some docs for setting up the .toml file were a little unclear to me. Especially, it wasn’t clear how to migrate from using the default [http_service] to [[services]]. Some trial and error later, this worked:

app = "campusninja"
primary_region = "ams"
console_command = "/rails/bin/rails console"

[processes]
  web = "./bin/rails server"
  cron = "supercronic ./crontab"

[[statics]]
  guest_path = "/rails/public"
  url_prefix = "/"

[[services]]
  processes = ["web"] # this service only applies to the web block
  http_checks = []
  internal_port = 3000
  protocol = "tcp"
  script_checks = []

  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

  [[services.ports]]
    handlers = ["http"]
    port = 80

  [[services.ports]]
    handlers = ["tls", "http"]
    port = 443

A plug-and-play solution would be really cool, but this also works. Thanks!

1 Like