channel-worker 2.0.1 → 2.0.3
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 +25 -2
- package/package.json +1 -1
package/lib/command-poller.js
CHANGED
|
@@ -334,6 +334,19 @@ class CommandPoller {
|
|
|
334
334
|
else if (fs.statSync(src).isDirectory()) fs.cpSync(src, dest, { recursive: true });
|
|
335
335
|
}
|
|
336
336
|
console.log(`[commands] CC extension downloaded to ${extPath}`);
|
|
337
|
+
|
|
338
|
+
// Close running profiles so they reload with new extension on next launch
|
|
339
|
+
if (this.nst) {
|
|
340
|
+
try {
|
|
341
|
+
const running = await this.nst.getRunningBrowsers();
|
|
342
|
+
if (running.length > 0) {
|
|
343
|
+
console.log(`[commands] Closing ${running.length} running profiles to reload extension...`);
|
|
344
|
+
for (const b of running) {
|
|
345
|
+
try { await this.nst.stopProfile(b.profileId); } catch {}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
} catch {}
|
|
349
|
+
}
|
|
337
350
|
} finally {
|
|
338
351
|
try { fs.unlinkSync(tmpArchive); } catch {}
|
|
339
352
|
try { fs.rmSync(tmpExtract, { recursive: true, force: true }); } catch {}
|
|
@@ -1155,6 +1168,7 @@ class CommandPoller {
|
|
|
1155
1168
|
|
|
1156
1169
|
// 6. Pick target profile — launch new if under limit, else assign to running
|
|
1157
1170
|
let target = null;
|
|
1171
|
+
console.log(`[scene-dispatch] running=${runningRenderers.length}/${parallelLimit} offline=${offlineRenderers.length} queue=${queueCount} names=[${runningRenderers.map(r=>r.name)}]`);
|
|
1158
1172
|
|
|
1159
1173
|
if (runningRenderers.length < parallelLimit && offlineRenderers.length > 0) {
|
|
1160
1174
|
// Under limit — launch a new profile first
|
|
@@ -1169,11 +1183,20 @@ class CommandPoller {
|
|
|
1169
1183
|
const baseExtPath = this.config.content_creator_ext_path || defaultCCExtPath;
|
|
1170
1184
|
await this._ensureContentCreatorExt(baseExtPath);
|
|
1171
1185
|
|
|
1172
|
-
// Create unique ext dir per profile
|
|
1186
|
+
// Create unique ext dir per profile + version (forces Chromium to reload SW)
|
|
1173
1187
|
let extensionPath = baseExtPath;
|
|
1174
1188
|
const fs = require('fs');
|
|
1175
|
-
const
|
|
1189
|
+
const extVersion = (() => { try { return JSON.parse(fs.readFileSync(path.join(baseExtPath, 'manifest.json'), 'utf8')).version; } catch { return '0'; } })();
|
|
1190
|
+
const uniqueExtPath = baseExtPath + '-' + target.nst_profile_id + '-v' + extVersion;
|
|
1176
1191
|
try {
|
|
1192
|
+
// Clean old version dirs for this profile
|
|
1193
|
+
const parent = path.dirname(baseExtPath);
|
|
1194
|
+
const prefix = path.basename(baseExtPath) + '-' + target.nst_profile_id;
|
|
1195
|
+
try {
|
|
1196
|
+
fs.readdirSync(parent)
|
|
1197
|
+
.filter(d => d.startsWith(prefix) && d !== path.basename(uniqueExtPath))
|
|
1198
|
+
.forEach(d => { try { fs.rmSync(path.join(parent, d), { recursive: true }); } catch {} });
|
|
1199
|
+
} catch {}
|
|
1177
1200
|
if (fs.existsSync(uniqueExtPath)) fs.rmSync(uniqueExtPath, { recursive: true });
|
|
1178
1201
|
fs.mkdirSync(uniqueExtPath, { recursive: true });
|
|
1179
1202
|
fs.cpSync(baseExtPath, uniqueExtPath, { recursive: true });
|