jsh daemonize with hot-reloading option #316
Merged
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.
This pull request introduces several updates to improve HTTP handling, enhance process management, and ensure thread safety in the codebase. Key changes include fixing HTTP method bindings, improving JSON and text body parsing, adding a reload mechanism for daemonized processes, and ensuring thread safety in WebSocket writes.
HTTP Handling Improvements:
new_server
by associatingpost
,put
, anddelete
with their respective handler methods instead oflsnr.Get
(mods/jsh/http/listener.go
).mkCtx
to properly parseapplication/json
,text/plain
, and other content types, ensuring the correct representation of the body in the request object (mods/jsh/http/router.go
).Process Management Enhancements:
realpath
function and awatcher
mechanism to support automatic reloads for daemonized processes. This includes monitoring file changes and restarting processes when necessary (mods/jsh/process.go
). [1] [2]Thread Safety Improvements:
sync.Mutex
) in theWsReadWriter
struct to ensure thread-safe writes to WebSocket connections (mods/server/http_util.go
). [1] [2]Logging Improvements:
Run
method to include panic messages and stack traces for better debugging (mods/jsh/jsh.go
).Dependency Updates:
encoding/json
andio
to support the new JSON and text parsing logic (mods/jsh/http/router.go
).