Rails and Resque setup

Hi, I recently deployed an app and a redis client. My app uses resque, and I can’t figure out how to get it to all work together to accept a background job. Can anyone walk me through this?

When I updated my fly.toml file as suggested in this guide, my deploys failed. For completeness, here is the file:

# fly.toml file generated for arelplane on 2022-10-28T18:42:53-04:00

app = "arelplane"
kill_signal = "SIGINT"
kill_timeout = 5
processes = []

[build]
  [build.args]
    BUILD_COMMAND = "bin/rails fly:build"
    SERVER_COMMAND = "bin/rails fly:server"

[deploy]
  release_command = "bin/rails fly:release"

[env]
  PORT = "8080"

[experimental]
  allowed_public_ports = []
  auto_rollback = true

[processes]
  web = "bin/rails fly:server"
  worker = "bundle exec rake resque:work"

[[services]]
  http_checks = []
  internal_port = 8080
  processes = ["web"]
  protocol = "tcp"
  script_checks = []
  [services.concurrency]
    hard_limit = 25
    soft_limit = 20
    type = "connections"

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

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

  [[services.tcp_checks]]
    grace_period = "1s"
    interval = "15s"
    restart_limit = 0
    timeout = "2s"

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

When I deploy I get the following error:

Listening on http://0.0.0.0:8080

2022-11-02T03:30:06.865 app[9dd722d1] ewr [info] Use Ctrl-C to stop

2022-11-02T03:30:16.967 runner[a42bd5e5] ewr [info] Shutting down virtual machine

2022-11-02T03:30:16.997 app[a42bd5e5] ewr [info] Sending signal SIGINT to main child process w/ PID 520

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] rails aborted!

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] Interrupt:

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/file_utils.rb:54:in `system'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/file_utils.rb:54:in `sh'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/lib/tasks/fly.rake:21:in `block (2 levels) in <main>'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rake.rb:20:in `execute'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:51:in `invoke'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] Tasks: TOP => fly:server

2022-11-02T03:30:17.003 app[a42bd5e5] ewr [info] (See full trace by running task with --trace)

2022-11-02T03:30:17.550 app[a42bd5e5] ewr [info] Starting clean up.

Any ideas here? I’m assuming I’m missing something super basic.

I fixed the scripts in the bin directory to set the current working directory a while back, but apparently neglected to update that page. Try:

[processes]
  web = "bin/rails fly:server"
  worker = "bin/bundle exec rake resque:work"

Thanks for the response. With that change I get the following build error:

rake aborted!

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] ArgumentError: Trying to register Bundler::GemfileError for status code 4 but Bundler::GemfileError is already registered

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] /app/config/boot.rb:3:in `require'

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] /app/config/boot.rb:3:in `<top (required)>'

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] /app/config/application.rb:1:in `require_relative'

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] /app/config/application.rb:1:in `<top (required)>'

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] /app/Rakefile:4:in `require_relative'

2022-11-02T15:12:01.604 app[d11bd905] ewr [info] /app/Rakefile:4:in `<top (required)>'

2022-11-02T15:12:01.844 app[d11bd905] ewr [info] Starting clean up.

2022-11-02T15:12:04.200 runner[b14978f6] ewr [info] Starting instance

2022-11-02T15:12:04.339 runner[b14978f6] ewr [info] Configuring virtual machine

2022-11-02T15:12:04.343 runner[b14978f6] ewr [info] Pulling container image

2022-11-02T15:12:04.827 runner[b14978f6] ewr [info] Unpacking image

2022-11-02T15:12:04.836 runner[b14978f6] ewr [info] Preparing kernel init

2022-11-02T15:12:05.150 runner[b14978f6] ewr [info] Configuring firecracker

2022-11-02T15:12:05.541 runner[b14978f6] ewr [info] Starting virtual machine

2022-11-02T15:12:05.701 app[b14978f6] ewr [info] Starting init (commit: ce4cf1b)...

2022-11-02T15:12:05.717 app[b14978f6] ewr [info] Preparing to run: `/bin/bash -o pipefail -c ${SERVER_COMMAND}` as root

2022-11-02T15:12:05.731 app[b14978f6] ewr [info] 2022/11/02 15:12:05 listening on [fdaa:0:c93f:a7b:7c:b149:78f6:2]:22 (DNS: [fdaa::3]:53)

2022-11-02T15:12:07.245 app[b14978f6] ewr [info] fallocate -l 512M /swapfile

2022-11-02T15:12:07.253 app[b14978f6] ewr [info] chmod 0600 /swapfile

2022-11-02T15:12:07.256 app[b14978f6] ewr [info] mkswap /swapfile

2022-11-02T15:12:07.263 app[b14978f6] ewr [info] Setting up swapspace version 1, size = 512 MiB (536866816 bytes)

2022-11-02T15:12:07.263 app[b14978f6] ewr [info] no label, UUID=cc7864fd-18a1-490f-8149-3ca6f67e22c7

2022-11-02T15:12:07.264 app[b14978f6] ewr [info] echo 10 > /proc/sys/vm/swappiness

2022-11-02T15:12:07.266 app[b14978f6] ewr [info] swapon /swapfile

2022-11-02T15:12:07.269 app[b14978f6] ewr [info] bin/rails server

2022-11-02T15:12:08.116 app[b14978f6] ewr [info] => Booting Puma

2022-11-02T15:12:08.116 app[b14978f6] ewr [info] => Rails 7.0.4 application starting in production

2022-11-02T15:12:08.116 app[b14978f6] ewr [info] => Run `bin/rails server --help` for more startup options

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] Puma starting in single mode...

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] * Puma version: 5.6.5 (ruby 3.1.2-p20) ("Birdie's Version")

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] * Min threads: 5

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] * Max threads: 5

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] * Environment: production

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] * PID: 531

2022-11-02T15:12:09.146 app[b14978f6] ewr [info] * Listening on http://0.0.0.0:8080

2022-11-02T15:12:09.149 app[b14978f6] ewr [info] Use Ctrl-C to stop

2022-11-02T15:12:18.731 runner[392fd0d8] ewr [info] Shutting down virtual machine

2022-11-02T15:12:19.011 app[392fd0d8] ewr [info] Sending signal SIGINT to main child process w/ PID 520

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] rails aborted!

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] Interrupt:

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/file_utils.rb:54:in `system'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/file_utils.rb:54:in `sh'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/lib/tasks/fly.rake:21:in `block (2 levels) in <main>'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `block in execute'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `each'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:281:in `execute'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/bugsnag-6.24.2/lib/bugsnag/integrations/rake.rb:20:in `execute'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:219:in `block in invoke_with_call_chain'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `synchronize'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:199:in `invoke_with_call_chain'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/task.rb:188:in `invoke'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:160:in `invoke_task'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block (2 levels) in top_level'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `each'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:116:in `block in top_level'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:125:in `run_with_threads'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:110:in `top_level'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block (2 levels) in perform'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/application.rb:186:in `standard_exception_handling'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:24:in `block in perform'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/rake-13.0.6/lib/rake/rake_module.rb:59:in `with_application'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands/rake/rake_command.rb:18:in `perform'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/command.rb:51:in `invoke'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/railties-7.0.4/lib/rails/commands.rb:18:in `<main>'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] /app/vendor/bundle/ruby/3.1.0/gems/bootsnap-1.13.0/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:32:in `require'

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] Tasks: TOP => fly:server

2022-11-02T15:12:19.017 app[392fd0d8] ewr [info] (See full trace by running task with --trace)

2022-11-02T15:12:20.033 app[392fd0d8] ewr [info] Starting clean up.

I’m also struggling to deploy with resque. Did you ever get it working @arelplane?