How to deploy solid_queue rails jobs using Kamal

187 views Asked by At

I am using kamal to deploy Rails web and jobs that run using solid_queue using bundle exec rake solid_queue:start Since the job runs and does not start a port with web service it does not pass health check. What are some other ways to deploy using kamal both web and jobs services.

2

There are 2 answers

2
microspino On

If you use Puma, an official plugin is available Add it to you puma.rb. It will allow Puma to manager and monitor the SolidQueue supervisor: no need to add a new container for it. We deployed it like this and works as expected.

Please note that, since Puma logs every transaction, depending on your solid_queue polling interval, your development log will likely be polluted with a lot of entries. To avoid this behaviour you can add config.solid_queue.silence_polling = true to your development.rb Hope this helps.

0
Luiz E. On

I am using web and job roles on my deployment config and I disabled traefik on job since it doesn't expose anything, there is no need to run health checks on it:

job:
  labels:
    traefik.enable: false
  hosts:
    - web
  env:
    clear:
      CRON_ENABLED: 1
      GOOD_JOB_MAX_THREADS: 10 # Number of threads to process background jobs
      DB_POOL: <%= 10 + 1 + 2 %> # GOOD_JOB_MAX_THREADS + 1 + 2
  cmd: "bundle exec good_job --queues '+urgent:7;*'"

in case you really want to add some health checks to your job process, check the documentation: https://kamal-deploy.org/docs/configuration, specially the "Using a custom healthcheck" part

you might need to update your job like this:

job:
  hosts:
    - web
  healthcheck:
    cmd: "bin/process_that_returns_a_non_zero_exit_code_when_healthy"
  env:
    clear:
      CRON_ENABLED: 1
      GOOD_JOB_MAX_THREADS: 10 # Number of threads to process background jobs
      DB_POOL: <%= 10 + 1 + 2 %> # GOOD_JOB_MAX_THREADS + 1 + 2
  cmd: "bundle exec good_job --queues '+urgent:7;*'"