ucode-agent 1.42.0 → 1.43.0
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/README.md +1 -1
- package/package.json +1 -1
- package/src/tools/shell.js +19 -0
- package/ucode.js +10 -0
package/README.md
CHANGED
package/package.json
CHANGED
package/src/tools/shell.js
CHANGED
|
@@ -183,6 +183,25 @@ export function serversReadySince(since = 0) {
|
|
|
183
183
|
return readyServers.filter((s) => s.at >= since);
|
|
184
184
|
}
|
|
185
185
|
|
|
186
|
+
/**
|
|
187
|
+
* Shut down every dev server this session started.
|
|
188
|
+
*
|
|
189
|
+
* killTree existed and nothing ever called it, so a server outlived the
|
|
190
|
+
* session that started it — every build left one behind. Twenty-four builds
|
|
191
|
+
* in one afternoon left seventy-three node processes running, the oldest for
|
|
192
|
+
* three and a half hours, holding ports the next run then could not use.
|
|
193
|
+
*
|
|
194
|
+
* Best effort and never throws: a process that has already gone is the
|
|
195
|
+
* outcome we wanted anyway.
|
|
196
|
+
*/
|
|
197
|
+
export function stopServers() {
|
|
198
|
+
const stopped = readyServers.splice(0, readyServers.length);
|
|
199
|
+
for (const s of stopped) {
|
|
200
|
+
try { killTree(s.pid); } catch { /* already gone */ }
|
|
201
|
+
}
|
|
202
|
+
return stopped.length;
|
|
203
|
+
}
|
|
204
|
+
|
|
186
205
|
/** Every server started this session, for reading what they have logged. */
|
|
187
206
|
export function runningServers() {
|
|
188
207
|
return readyServers.slice();
|
package/ucode.js
CHANGED
|
@@ -145,6 +145,16 @@ async function main() {
|
|
|
145
145
|
await agent.persist().catch(() => {});
|
|
146
146
|
agent.ui.close();
|
|
147
147
|
process.exitCode = 1;
|
|
148
|
+
} finally {
|
|
149
|
+
// Take the dev servers down with the session that started them, however it
|
|
150
|
+
// ended. killTree was written for this and nothing ever called it, so every
|
|
151
|
+
// build left its server running: twenty-four builds in an afternoon left
|
|
152
|
+
// seventy-three node processes alive, the oldest for three and a half
|
|
153
|
+
// hours, holding the ports the next run wanted.
|
|
154
|
+
try {
|
|
155
|
+
const { stopServers } = await import('./src/tools/shell.js');
|
|
156
|
+
stopServers();
|
|
157
|
+
} catch { /* nothing started, or already gone */ }
|
|
148
158
|
}
|
|
149
159
|
}
|
|
150
160
|
|