Shell 1.9.1: a module update actually runs the updated code #28
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "proddash",
|
"name": "proddash",
|
||||||
"version": "1.9.0",
|
"version": "1.9.1",
|
||||||
"private": true,
|
"private": true,
|
||||||
"description": "Modular production dashboard for Waters Church \u2014 zero-dependency Node server + vanilla client",
|
"description": "Modular production dashboard for Waters Church \u2014 zero-dependency Node server + vanilla client",
|
||||||
"license": "UNLICENSED",
|
"license": "UNLICENSED",
|
||||||
|
|||||||
@@ -373,7 +373,18 @@ function mountModule(id) {
|
|||||||
const log = makeLog(id);
|
const log = makeLog(id);
|
||||||
try {
|
try {
|
||||||
const serverPath = path.join(man.dir, man.server);
|
const serverPath = path.join(man.dir, man.server);
|
||||||
// Re-require fresh config on every (re)mount; the module code itself stays cached.
|
// Drop the module's code from the require cache so every (re)mount runs
|
||||||
|
// the files on disk. Without this a module UPDATE swaps the folder while
|
||||||
|
// the process keeps executing the old code until ProdDash itself
|
||||||
|
// restarts — the manifest (read fresh from disk) then reports a version
|
||||||
|
// the running code isn't, and anything new in the update silently
|
||||||
|
// doesn't happen. Modules already have to come up clean on re-init
|
||||||
|
// (module guide), so a fresh load on config remounts is the same
|
||||||
|
// contract without the trap.
|
||||||
|
const cachePrefix = man.dir.endsWith(path.sep) ? man.dir : man.dir + path.sep;
|
||||||
|
for (const key of Object.keys(require.cache)) {
|
||||||
|
if (key.startsWith(cachePrefix)) delete require.cache[key];
|
||||||
|
}
|
||||||
const mod = require(serverPath);
|
const mod = require(serverPath);
|
||||||
const config = effectiveConfig(id);
|
const config = effectiveConfig(id);
|
||||||
// What a module needs to reach the rest of ProdDash — another module's
|
// What a module needs to reach the rest of ProdDash — another module's
|
||||||
|
|||||||
Reference in New Issue
Block a user