solid_queue icon indicating copy to clipboard operation
solid_queue copied to clipboard

Puma plugin fails

Open kristian-nst opened this issue 4 months ago • 5 comments

only added plugin :solid_queue to the default puma.rb file

Puma starting in single mode...
* Puma version: 6.6.1 ("Return to Forever")
* Ruby version: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24]
*  Min threads: 5
*  Max threads: 5
*  Environment: development
*          PID: 37781
* Listening on http://0.0.0.0:3000
Use Ctrl-C to stop
objc[37819]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
objc[37819]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
Detected Solid Queue has gone away, stopping Puma...
- Gracefully stopping, waiting for requests to finish
=== puma shutdown: 2025-08-23 21:42:00 +0800 ===
- Goodbye!
Exiting

solid_queue 1.2.1 rails 8.0.1 puma 6.6.1

kristian-nst avatar Aug 23 '25 13:08 kristian-nst

Hi, I think "the plugin requires app preloading to work" (from README) is the reason. You need to start Puma in cluster mode.

inquisitivus avatar Aug 23 '25 14:08 inquisitivus

I tried:

23:05:40 web.1  | [497] Puma starting in cluster mode...
23:05:40 web.1  | [497] * Puma version: 6.6.1 ("Return to Forever")
23:05:40 web.1  | [497] * Ruby version: ruby 3.3.6 (2024-11-05 revision 75015d4c1f) [arm64-darwin24]
23:05:40 web.1  | [497] *  Min threads: 5
23:05:40 web.1  | [497] *  Max threads: 5
23:05:40 web.1  | [497] *  Environment: development
23:05:40 web.1  | [497] *   Master PID: 497
23:05:40 web.1  | [497] *      Workers: 3
23:05:40 web.1  | [497] *     Restarts: (✔) hot (✖) phased (✖) refork
23:05:40 web.1  | [497] * Preloading application
23:05:40 web.1  | [497] * Listening on http://127.0.0.1:3000
23:05:40 web.1  | [497] * Listening on http://[::1]:3000
23:05:40 web.1  | [497] Use Ctrl-C to stop
23:05:40 web.1  | [497] - Worker 0 (PID: 519) booted in 0.01s, phase: 0
23:05:40 web.1  | [497] - Worker 1 (PID: 520) booted in 0.01s, phase: 0
23:05:40 web.1  | [497] - Worker 2 (PID: 524) booted in 0.01s, phase: 0
23:05:40 web.1  | objc[525]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called.
23:05:40 web.1  | objc[525]: +[__NSCFConstantString initialize] may have been in progress in another thread when fork() was called. We cannot safely call it or ignore it in the fork() child process. Crashing instead. Set a breakpoint on objc_initializeAfterForkError to debug.
23:05:40 web.1  | [497] ! reaped unknown child process pid=525 status=pid 525 SIGABRT (signal 6)
23:05:40 css.1  | Browserslist: caniuse-lite is outdated. Please run:
23:05:40 css.1  |   npx update-browserslist-db@latest
23:05:40 css.1  |   Why you should do it regularly: https://github.com/browserslist/update-db#readme
23:05:40 css.1  | 
23:05:40 css.1  | Rebuilding...
23:05:40 css.1  | 
23:05:40 css.1  | Done in 231ms.
23:05:42 web.1  | [497] Detected Solid Queue has gone away, stopping Puma...
23:05:42 web.1  | [497] - Gracefully shutting down workers...
ç^C23:05:52 system | SIGINT received, starting shutdown
23:05:52 web.1  | [497] === puma shutdown: 2025-08-23 23:05:52 +0800 ===
23:05:52 web.1  | [497] - Goodbye!
23:05:52 web.1  | Exiting
23:05:53 system | sending SIGTERM to all processes
23:05:53 css.1  | exited with code 0
23:05:53 web.1  | exited with code 0

puma.rb

threads_count = ENV.fetch('RAILS_MAX_THREADS', 5)
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
port ENV.fetch('PORT', 3000)

# Allow puma to be restarted by `bin/rails restart` command.
plugin :tmp_restart

# Run the Solid Queue supervisor inside of Puma for single-server deployments
workers 3
preload_app!
plugin :solid_queue

# Specify the PID file. Defaults to tmp/pids/server.pid in development.
# In other environments, only set the PID file if requested.
pidfile ENV['PIDFILE'] if ENV['PIDFILE']

kristian-nst avatar Aug 23 '25 15:08 kristian-nst

@kristian-nst , I've just created fresh new rails app with all default settings using ruby 3.3.9 and your gems versions. It's successfully started with puma plugin in cluster and single mode. My OS is Ubuntu 25.04, btw. Maybe, you need to check other gems, ruby or OS? I'm just user of this gem and I've had same problem some time ago, but it works now)

inquisitivus avatar Aug 26 '25 20:08 inquisitivus

@kristian-nst , I've just created fresh new rails app with all default settings using ruby 3.3.9 and your gems versions. It's successfully started with puma plugin in cluster and single mode. My OS is Ubuntu 25.04, btw. Maybe, you need to check other gems, ruby or OS? I'm just user of this gem and I've had same problem some time ago, but it works now)

Ah, perhaps a MacOS issue 🤔 But no further investigation yet..

Frexuz avatar Aug 28 '25 13:08 Frexuz

@kristian-nst , try to put this in your .bashrc (or .zshrc if you use zsh) : export OBJC_DISABLE_INITIALIZE_FORK_SAFETY=yes

nflorentin avatar Oct 31 '25 14:10 nflorentin