Reload code in place instead of restarting the server - #37
Open
afomera wants to merge 1 commit into
Open
Conversation
Reloading ran through Guard, which restarted the whole Puma process on every file change. Hanami can now reload in place via `Hanami::Slice#reload!`, so the server stays up. `hanami server` wraps the app in a Rack middleware that checks for changed files once per request and reloads before dispatching, so a reload only happens when there is something to serve and never lands mid-edit. The middleware has to sit outside `Hanami.app`, since a reload replaces its middleware stack: `Server` subclasses `Hanami::CLI::Server` to reach the app between the rack config file being read and the server starting, inheriting its option mapping and choice of rack server. A reload that raises is not committed, so the next request retries once the file is fixed. Guard and guard-puma are no longer needed, and `hanami install` now removes the Guardfile it used to generate.
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.
Reloading ran through Guard, which restarted the whole Puma process on every file change. Hanami can now reload in place via
Hanami::Slice#reload!, so the server stays up.hanami serverwraps the app in a Rack middleware that checks for changed files once per request and reloads before dispatching, so a reload only happens when there is something to serve and never lands mid-edit. The middleware has to sit outsideHanami.app, since a reload replaces its middleware stack:ServersubclassesHanami::CLI::Serverto reach the app between the rack config file being read and the server starting, inheriting its option mapping and choice of rack server. A reload that raises is not committed, so the next request retries once the file is fixed.Guard and guard-puma are no longer needed, and
hanami installnow removes the Guardfile it used to generate.Depends on hanami/hanami#1625, once that is merged I can remove the gemfile update!