Skip to content

jsh daemonize with hot-reloading option #316

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 9, 2025
Merged

jsh daemonize with hot-reloading option #316

merged 3 commits into from
May 9, 2025

Conversation

OutOfBedlam
Copy link
Contributor

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:

  • Corrected HTTP method bindings in new_server by associating post, put, and delete with their respective handler methods instead of lsnr.Get (mods/jsh/http/listener.go).
  • Enhanced request body handling in mkCtx to properly parse application/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:

  • Added a realpath function and a watcher 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:

  • Introduced a mutex (sync.Mutex) in the WsReadWriter struct to ensure thread-safe writes to WebSocket connections (mods/server/http_util.go). [1] [2]

Logging Improvements:

  • Enhanced error logging in the Run method to include panic messages and stack traces for better debugging (mods/jsh/jsh.go).

Dependency Updates:

  • Added imports for encoding/json and io to support the new JSON and text parsing logic (mods/jsh/http/router.go).

Copy link

codecov bot commented May 9, 2025

Codecov Report

Attention: Patch coverage is 7.84314% with 94 lines in your changes missing coverage. Please review.

Project coverage is 41.73%. Comparing base (6b0945a) to head (c7d598e).
Report is 1 commits behind head on main.

Files with missing lines Patch % Lines
mods/jsh/process.go 0.00% 75 Missing ⚠️
mods/jsh/http/router.go 23.80% 13 Missing and 3 partials ⚠️
mods/server/http_util.go 0.00% 2 Missing ⚠️
mods/jsh/jsh.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #316      +/-   ##
==========================================
- Coverage   41.79%   41.73%   -0.07%     
==========================================
  Files         282      282              
  Lines       60372    60467      +95     
==========================================
+ Hits        25233    25234       +1     
- Misses      32543    32633      +90     
- Partials     2596     2600       +4     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@OutOfBedlam OutOfBedlam merged commit 72c0cac into main May 9, 2025
8 of 10 checks passed
@OutOfBedlam OutOfBedlam deleted the work-jsh-http branch May 9, 2025 03:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant