Setting Up Campfire on Localhost
David Kimura at Drifting Ruby has some good videos on setting Campfire up outside the Once installer. Outside of the 3.3 RC1 and stringio issues, I was running into another issue: I could not generate thumbnails when running on localhost. The thumbnails generated as expected when using Puma Dev. Still, on localhost, they were failing, and worse, I would typically end up with one broken thumbnail variant per thread pool worker.
First, here are my setup steps:
- Download the source
- Run bin/setup (I had to remove rbenv from this file since I use ASDF these days)
- From the rails console, run,
WebPush.generate_key
and copy the keys into ENV variablesVAPID_PUBLIC_KEY
andVAPID_PRIVATE_KEY
- Add the
msgpack
gem to my GemFile
With all of this in place, https://campfire.test worked as expected.
However, when starting the server via bundle exec rails server
(on an M1 MBP with Sonoma 14.3), the thumbnails of images were missing. I could click on the thumbnails and see them in the lightbox but not in the chat window.
Digging into the database, I could see they were not being analyzed, but I had no idea why.
Then I saw the following in the logs:
|
|
The thread running ActiveJob running the ActiveStorage Analyze job was crashing.
A little searching led me to this bug thread and a suggestion to set OBJC_DISABLE_INITIALIZE_FORK_SAFETY=YES
. A quick server reboot, and everything works as expected.
Before I got here, I also tried disabling cluster mode in Puma, WEB_CONCURRENCY=0 bundle exec rails s
, which solved the problem.
I submitted this as a bug to 37Signals. I am not sure if this is just something on my computer or not, so I would try it without these changes first.
Update: 37Signals confirmed this is a known issue. The env variable is actually set in the .pumadev
file which is why I did. not see the issue when using Puma Dev.