channel-worker 2.2.3 → 2.2.5
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/lib/command-poller.js +22 -4
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -1214,9 +1214,17 @@ class CommandPoller {
|
|
|
1214
1214
|
const stillOffline = renderers.filter(r => !runningRenderers.includes(r));
|
|
1215
1215
|
console.log(`[scene-dispatch] running=${runningRenderers.length}/${parallelLimit} offline=${stillOffline.length} queue=${queueCount} names=[${runningRenderers.map(r=>r.name)}]`);
|
|
1216
1216
|
|
|
1217
|
-
//
|
|
1218
|
-
|
|
1219
|
-
const
|
|
1217
|
+
// Count how many running profiles are actually free (no commands)
|
|
1218
|
+
let freeRunning = 0;
|
|
1219
|
+
for (const r of runningRenderers) {
|
|
1220
|
+
try {
|
|
1221
|
+
const c = await this.api.rendererHasCommands(r.nst_profile_id);
|
|
1222
|
+
if (c === 0) freeRunning++;
|
|
1223
|
+
} catch {}
|
|
1224
|
+
}
|
|
1225
|
+
// Only launch new profiles if queue has more work than free profiles
|
|
1226
|
+
const needNew = Math.max(0, queueCount - freeRunning);
|
|
1227
|
+
const neededLaunches = Math.min(parallelLimit - runningRenderers.length, stillOffline.length, needNew);
|
|
1220
1228
|
for (let li = 0; li < neededLaunches; li++) {
|
|
1221
1229
|
const toLaunch = stillOffline[li];
|
|
1222
1230
|
console.log(`[scene-dispatch] Launching ${toLaunch.name} (running: ${runningRenderers.length + li}/${parallelLimit})`);
|
|
@@ -1315,7 +1323,17 @@ class CommandPoller {
|
|
|
1315
1323
|
const lastActivity = this._profileLastActivity[profileId]
|
|
1316
1324
|
|| (name && this._profileLastActivity[name])
|
|
1317
1325
|
|| 0;
|
|
1318
|
-
|
|
1326
|
+
// If not tracked: check if it has commands — if not, close it (orphaned profile)
|
|
1327
|
+
if (!lastActivity) {
|
|
1328
|
+
try {
|
|
1329
|
+
const cmdCount = name ? await this.api.rendererHasCommands(name) : 0;
|
|
1330
|
+
if (cmdCount > 0) continue; // has work, skip
|
|
1331
|
+
} catch {}
|
|
1332
|
+
// No commands + not tracked = orphaned, close
|
|
1333
|
+
console.log(`[profile-timeout] Closing orphaned profile ${browser.name || profileId} (not tracked, no commands)`);
|
|
1334
|
+
try { await this.nst.stopProfile(profileId); } catch {}
|
|
1335
|
+
continue;
|
|
1336
|
+
}
|
|
1319
1337
|
if ((now - lastActivity) > IDLE_TIMEOUT) {
|
|
1320
1338
|
console.log(`[profile-timeout] Closing idle profile ${browser.name || profileId} (idle ${Math.round((now - lastActivity) / 1000)}s)`);
|
|
1321
1339
|
try {
|