castle-web-cli 0.4.9 → 0.4.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/serve.js +8 -3
- package/package.json +1 -1
package/dist/serve.js
CHANGED
|
@@ -210,12 +210,17 @@ async function serveDetached(projectDir, options) {
|
|
|
210
210
|
args.push('--host', options.host);
|
|
211
211
|
if (options.open)
|
|
212
212
|
args.push('--open');
|
|
213
|
-
//
|
|
213
|
+
// CASTLE_WEB_CLI_DETACH=1 → spawn as a new session leader (fully
|
|
214
|
+
// independent; survives caller). This is the eval-harness mode where the
|
|
215
|
+
// harness manages cleanup itself.
|
|
216
|
+
// Default → child stays in the caller's process group / session, so when
|
|
214
217
|
// the agent / shell that invoked `castle-web init` exits, SIGHUP reaches
|
|
215
|
-
// this serve and it dies with the session.
|
|
216
|
-
// the calling node process exit
|
|
218
|
+
// this serve and it dies with the session.
|
|
219
|
+
// `.unref()` is what lets the calling node process exit either way.
|
|
220
|
+
const fullDetach = process.env.CASTLE_WEB_CLI_DETACH === '1';
|
|
217
221
|
const child = spawn(process.execPath, [entry, ...args], {
|
|
218
222
|
cwd: projectDir,
|
|
223
|
+
detached: fullDetach,
|
|
219
224
|
stdio: ['ignore', logFd, logFd],
|
|
220
225
|
env: process.env,
|
|
221
226
|
});
|