mirror of
https://github.com/Pasta-Devs/Marinara-Engine.git
synced 2026-12-03 19:00:50 +07:00
[PR #463] [MERGED] feat(env): hot-reload .env changes without restarting the server #4629
Labels
No labels
android
bug
bugfix
ci
client
code freeze pause
container
dependencies
docs
documentation
duplicate
enhancement
feature
feature
feature
feature-creep
fixed-in-refactor
fixed-in-staging
good first issue
help wanted
in-pr
in-pr
needs-codeowner-decision
normal-scope
old-codebase
old-codebase
pull-request
qol
question
refactor
regression
revisit later
roadmap
scope-risk
scope-risk
server
server
shared
soup
upstream
windows
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
Pasta-Devs/Marinara-Engine#4629
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
📋 Pull Request Information
Original PR: https://github.com/Pasta-Devs/Marinara-Engine/pull/463
Author: @LukaTheHero
Created: 5/6/2026
Status: ✅ Merged
Merged: 5/6/2026
Merged by: @LukaTheHero
Base:
main← Head:feat/env-hot-reload📝 Commits (1)
e62dcddfeat(env): hot-reload .env changes without restarting the server📊 Changes
5 files changed (+243 additions, -5 deletions)
View changed files
📝
docs/CONFIGURATION.md(+2 -0)📝
docs/REMOTE_ACCESS.md(+9 -3)➕
packages/server/src/config/env-watcher.ts(+156 -0)📝
packages/server/src/config/runtime-config.ts(+73 -2)📝
packages/server/src/index.ts(+3 -0)📄 Description
Summary
.envand propagates added / updated / removed keys toprocess.envon save.runtime-config.tsgetters that re-evaluateprocess.envper request, so changes toBASIC_AUTH_USER/BASIC_AUTH_PASS/BASIC_AUTH_REALM,IP_ALLOWLIST/IP_ALLOWLIST_ENABLED,ADMIN_SECRET,CSRF_TRUSTED_ORIGINS,TRUSTED_PRIVATE_NETWORKS, and theALLOW_UNAUTHENTICATED_*/*_LOCAL_URLS_ENABLEDflags now take effect on the next request — no restart required.PORT,HOST,SSL_CERT/SSL_KEY,CORS_ORIGINS, storage paths,ENCRYPTION_KEY,TZ,AUTO_OPEN_*) still need a restart; the watcher logs a warning identifying which one changed so users aren't left wondering why nothing happened.Why
Users adding access-control settings (Basic Auth, IP allowlist) hit a recurring papercut: edit
.env, forget to restart, conclude the feature is broken, file an issue. The middleware was already architected for per-request reads — the only blocker was a one-timedotenv.config()guard at module load. This PR adds a polling watcher (2 sfs.watchFile) and areloadRuntimeEnv()helper that re-parses the file and applies the diff toprocess.env(including key removal, so unsetting a value works).LOG_LEVELchanges also flow through to the live pino logger.What changed
packages/server/src/config/runtime-config.ts—loadRuntimeEnv()now records the keys it set; newreloadRuntimeEnv()returns an{ added, updated, removed, unchanged }diff after re-parsing.packages/server/src/config/env-watcher.ts(new) — polling watcher, debounces by mtime + size, masks sensitive values (BASIC_AUTH_PASS,ADMIN_SECRET,ENCRYPTION_KEY,GIPHY_API_KEY) when logging, warns on restart-required keys, appliesLOG_LEVELlive.packages/server/src/index.ts— starts the watcher afterbuildApp(), stops it on graceful shutdown.docs/REMOTE_ACCESS.md+docs/CONFIGURATION.md— new "When a restart is required" section + tweaked the "restart Marinara" wording in the access-control walkthrough.Notes
CONTRIBUTING.md, one should be opened describing the user-facing problem (Basic Auth / IP allowlist feedback loop friction) before this is merged.fs.watchFileoverfs.watchfor cross-platform reliability (editors that write via temp-file + atomic rename breakfs.watchon Windows).Summary by CodeRabbit
Release Notes
New Features
Documentation
🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.