@paleo/workspace 0.14.0 → 0.14.1
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/dev-server.d.ts +6 -0
- package/dist/dev-server.js +24 -0
- package/package.json +1 -1
package/dist/dev-server.d.ts
CHANGED
|
@@ -33,6 +33,12 @@ export interface DevServerSummaryContext {
|
|
|
33
33
|
}[];
|
|
34
34
|
}
|
|
35
35
|
export declare function runDevServer(config: DevServerConfig): Promise<void>;
|
|
36
|
+
/**
|
|
37
|
+
* Poll the foreground's own spawn PIDs; when none remain alive, the servers were stopped from
|
|
38
|
+
* outside this process (`dev down`, `down --all`, eviction, or a manual kill). Fires `onStopped`
|
|
39
|
+
* once so the foreground can exit instead of hanging on dead servers.
|
|
40
|
+
*/
|
|
41
|
+
export declare function watchForExternalStop(pids: number[], onStopped: () => void, isAlive?: (pid: number) => boolean, intervalMs?: number): NodeJS.Timeout | undefined;
|
|
36
42
|
export type WorktreeReadyCheck = {
|
|
37
43
|
ok: true;
|
|
38
44
|
} | {
|
package/dist/dev-server.js
CHANGED
|
@@ -136,6 +136,13 @@ async function runForeground(config, mainWorktree, options) {
|
|
|
136
136
|
started = true;
|
|
137
137
|
printStartSummary(config, slot, state.spawnPids);
|
|
138
138
|
tailLogs(config, state.spawnPids);
|
|
139
|
+
watchForExternalStop(Object.values(state.spawnPids), () => {
|
|
140
|
+
if (shuttingDown)
|
|
141
|
+
return;
|
|
142
|
+
shuttingDown = true;
|
|
143
|
+
console.log("\nDev-server stopped externally (e.g. `dev down`). Exiting.");
|
|
144
|
+
process.exit(0);
|
|
145
|
+
});
|
|
139
146
|
await new Promise(() => { });
|
|
140
147
|
}
|
|
141
148
|
async function shutdownForeground(config, mainWorktree) {
|
|
@@ -203,6 +210,7 @@ function printStartSummary(config, slot, spawnPids) {
|
|
|
203
210
|
}
|
|
204
211
|
}
|
|
205
212
|
const TAIL_INTERVAL_MS = 300;
|
|
213
|
+
const LIVENESS_POLL_MS = 1000;
|
|
206
214
|
function tailLogs(config, spawnPids) {
|
|
207
215
|
const names = Object.keys(spawnPids);
|
|
208
216
|
const prefixed = names.length > 1;
|
|
@@ -231,6 +239,22 @@ function followLogFile(path, prefix) {
|
|
|
231
239
|
process.stdout.write(prefix === "" ? text : text.replace(/^(?=.)/gm, prefix));
|
|
232
240
|
}, TAIL_INTERVAL_MS);
|
|
233
241
|
}
|
|
242
|
+
/**
|
|
243
|
+
* Poll the foreground's own spawn PIDs; when none remain alive, the servers were stopped from
|
|
244
|
+
* outside this process (`dev down`, `down --all`, eviction, or a manual kill). Fires `onStopped`
|
|
245
|
+
* once so the foreground can exit instead of hanging on dead servers.
|
|
246
|
+
*/
|
|
247
|
+
export function watchForExternalStop(pids, onStopped, isAlive = isProcessAlive, intervalMs = LIVENESS_POLL_MS) {
|
|
248
|
+
if (pids.length === 0)
|
|
249
|
+
return;
|
|
250
|
+
const timer = setInterval(() => {
|
|
251
|
+
if (pids.some(isAlive))
|
|
252
|
+
return;
|
|
253
|
+
clearInterval(timer);
|
|
254
|
+
onStopped();
|
|
255
|
+
}, intervalMs);
|
|
256
|
+
return timer;
|
|
257
|
+
}
|
|
234
258
|
async function rollbackStart(spawnPids, startedCallbacks, ctx) {
|
|
235
259
|
console.error("\nStopping dev servers...");
|
|
236
260
|
for (const pid of Object.values(spawnPids)) {
|