Change async behaviour of replicate and other commands#62
Merged
fractaledmind merged 2 commits intofractaledmind:mainfrom Jun 13, 2025
Merged
Change async behaviour of replicate and other commands#62fractaledmind merged 2 commits intofractaledmind:mainfrom
fractaledmind merged 2 commits intofractaledmind:mainfrom
Conversation
a8926c1 to
2aec3b1
Compare
2aec3b1 to
c5a557f
Compare
Owner
fractaledmind
left a comment
There was a problem hiding this comment.
I have some questions. I like the idea and certainly want to improve this area, but I don't fully grok everything yet.
Owner
|
This feels like it should be a code comment somewhere appropriate:
|
Contributor
Author
|
Thanks for the great suggestions! Good call on the comment, moved it to the replicate command method.
Sure thing! Let me know how I can help 🙌 |
Owner
|
Released in v0.14.0 |
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.
First of all: Kickass gem, thanks for creating it! I'm surprised this has only 200 stars. You'd think with everyone using SQLite in their new Rails apps a lot more people would use this too 🤷
Anyways. This addresses #42 and some other issues related to running Litestream rake tasks. The existing implementation would run any command as a forked process. This leads to problems when running replication from the command line or through Foreman.
# Forks the process and exits. Troublesome to stop on the command line, screws with Foreman and other process monitors rails litestream:replicateThe way I think about it, there are two types of Litestream commands: short-running ones and long-running ones. The only long-running command is
replicate. Any other command will exit quickly, whilereplicatewill keep running until terminated.replicatewill be started as a fork or in the same process, depending on the context. Puma will start replication as a forked process, while the rake tasks don't. When running in-process, we capture output continuously and write to stdout.This separation allows for simplification of arguments. We no longer need the
async: truefor short-running commands. Table formatting is also simplified, as most short-running commands output a tabular format. The only exception is the restore command.Short-running commands now always return a hash, which is converted to a tabular output in the Rake task and then printed.
Testing
I gave my fork a go with one of my apps, running the various rake tasks, running in Puma, and so on. Caught a bunch of issues, hopefully got them all.
Other Changes
sqlite3conflict (?) when trying to run tests 🤷sqlite3development dependency.If you'd rather have a separate PR for the various little bits let me know, happy to take them out and move to a separate PR.