Support Puma >= 7 in the puma plugin - #3
Merged
Merged
Conversation
Puma 7 (puma#3438) renamed the lifecycle event hooks the plugin relies on, so on Puma >= 7 Litestream replication was never started or stopped alongside Puma. Version-gate on Puma::Const::VERSION, mirroring solid_queue: on_booted -> after_booted on_stopped -> after_stopped on_restart -> before_restart Puma < 7 keeps the old hook names, so existing users are unaffected. The fork + monitor setup is extracted into a private start_litestream method shared by both branches. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Context
lib/puma/plugin/litestream.rbwas copied from an oldsolid_queuecommit and registers lifecycle hooks vialauncher.events.on_booted/on_stopped/on_restart. Puma 7 (puma#3438) renamed these hooks, so on Puma >= 7 Litestream replication was never started or stopped alongside Puma.Change
Version-gate on
Puma::Const::VERSION, mirroringsolid_queuemain (PR rails/solid_queue#635):on_bootedafter_bootedon_stoppedafter_stoppedon_restartbefore_restartThe fork + monitor setup is extracted into a private
start_litestreammethod shared by both branches. Puma < 7 keeps the old hook names, so existing users are unaffected.solid_queue's
:asyncDSL mode and its extra guards are intentionally not ported — they exist there only because it movedin_backgroundout of the booted block. Litestream always forks an external binary, soin_backgroundstays insidestart_litestream(after the pid is assigned) and no nil-pid guard is needed.Verification
No puma dependency is declared in the gemspec and no plugin test exists, so this is a manual check:
ruby -c lib/puma/plugin/litestream.rb— syntax OKplugin :litestreamunder Puma 7; confirm replication starts on boot and stops on restart, with noundefined method/ deprecation warningson_*branch still works🤖 Generated with Claude Code