channel-worker 2.0.0 → 2.0.2

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.
@@ -1144,25 +1144,21 @@ class CommandPoller {
1144
1144
  const running = await this.nst.getRunningBrowsers();
1145
1145
  const runningIds = new Set(running.map(b => b.profileId));
1146
1146
 
1147
- // 5. Match renderers to running profiles
1147
+ // 5. Match renderers to running profiles (by name or UUID)
1148
+ const runningByName = {};
1149
+ for (const b of running) { if (b.name) runningByName[b.name.toLowerCase()] = b.profileId; }
1148
1150
  const runningRenderers = renderers.filter(r => {
1149
- const profileId = this.nst.isUUID(r.nst_profile_id)
1150
- ? r.nst_profile_id
1151
- : this._resolvedProfiles?.[r.nst_profile_id];
1152
- return profileId && runningIds.has(profileId);
1151
+ if (this.nst.isUUID(r.nst_profile_id) && runningIds.has(r.nst_profile_id)) return true;
1152
+ return !!runningByName[r.nst_profile_id.toLowerCase()];
1153
1153
  });
1154
1154
  const offlineRenderers = renderers.filter(r => !runningRenderers.includes(r));
1155
1155
 
1156
- // 6. Pick target profile
1156
+ // 6. Pick target profile — launch new if under limit, else assign to running
1157
1157
  let target = null;
1158
+ console.log(`[scene-dispatch] running=${runningRenderers.length}/${parallelLimit} offline=${offlineRenderers.length} queue=${queueCount} names=[${runningRenderers.map(r=>r.name)}]`);
1158
1159
 
1159
- if (runningRenderers.length > 0) {
1160
- // Assign to a running renderer (round-robin by name for simplicity)
1161
- target = runningRenderers[0]; // TODO: could pick least loaded
1162
- }
1163
-
1164
- if (!target && runningRenderers.length < parallelLimit && offlineRenderers.length > 0) {
1165
- // Under limit — launch a new profile
1160
+ if (runningRenderers.length < parallelLimit && offlineRenderers.length > 0) {
1161
+ // Under limit launch a new profile first
1166
1162
  target = offlineRenderers[0];
1167
1163
  console.log(`[scene-dispatch] Launching ${target.name} (running: ${runningRenderers.length}/${parallelLimit})`);
1168
1164
  try {
@@ -1201,8 +1197,13 @@ class CommandPoller {
1201
1197
  }
1202
1198
  }
1203
1199
 
1200
+ // Fallback: assign to least loaded running renderer
1201
+ if (!target && runningRenderers.length > 0) {
1202
+ target = runningRenderers[0]; // extension processes commands sequentially per profile
1203
+ }
1204
+
1204
1205
  if (!target) {
1205
- // At limit, no running renderers available — wait for next cycle
1206
+ // No renderers available at all — wait for next cycle
1206
1207
  this._dispatching = false;
1207
1208
  return;
1208
1209
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "channel-worker",
3
- "version": "2.0.0",
3
+ "version": "2.0.2",
4
4
  "description": "Channel Manager worker daemon — runs on remote machines to execute video pipeline jobs",
5
5
  "main": "lib/daemon.js",
6
6
  "bin": {