@nsshunt/stsrunnerframework 2.0.1 → 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.
|
@@ -5682,78 +5682,89 @@ var ArchiveManager = class {
|
|
|
5682
5682
|
* If matching runners were found, process them after a short delay.
|
|
5683
5683
|
* Otherwise just schedule the next scan loop.
|
|
5684
5684
|
*/
|
|
5685
|
-
if (removeList.length > 0)
|
|
5686
|
-
|
|
5687
|
-
|
|
5688
|
-
|
|
5689
|
-
|
|
5690
|
-
|
|
5691
|
-
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
* Stop any active telemetry/instrument publishing for this runner.
|
|
5697
|
-
*
|
|
5698
|
-
* This is done before archive/delete handling so no further
|
|
5699
|
-
* publishing occurs after the runner is considered retired.
|
|
5700
|
-
*/
|
|
5701
|
-
if (runnerEx.publishInstrumentController) {
|
|
5702
|
-
this.options.logger.debug(import_source.default.grey(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5703
|
-
runnerEx.publishInstrumentController.EndPublish();
|
|
5704
|
-
}
|
|
5705
|
-
/**
|
|
5706
|
-
* Only non-terminated runners are stored in the archive list.
|
|
5707
|
-
*
|
|
5708
|
-
* Terminated runners are treated as retired/removed but not archived.
|
|
5709
|
-
*/
|
|
5710
|
-
if (runnerEx.state !== IRunnerState.terminated) {
|
|
5711
|
-
this.options.logger.debug(import_source.default.grey(`Archive runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5712
|
-
const runner = runnerEx.toRunner();
|
|
5713
|
-
this.archiveList.push(runner);
|
|
5685
|
+
if (removeList.length > 0) {
|
|
5686
|
+
const startTimeout = setTimeout(async () => {
|
|
5687
|
+
this.options.logger.debug(import_source.default.grey(`STSWorkerManager:_processLoopExecutor(): Removing runners from collection: [${JSON.stringify(removeList)}]`));
|
|
5688
|
+
/**
|
|
5689
|
+
* Process each matched runner from the temporary remove list.
|
|
5690
|
+
*/
|
|
5691
|
+
for (let i = 0; i < removeList.length; i++) {
|
|
5692
|
+
const workerEx = this.options.workerRegistry.GetWorkerEx(removeList[i].workerId);
|
|
5693
|
+
if (workerEx) {
|
|
5694
|
+
const runnerEx = workerEx.GetRunnerEx(removeList[i].runnerId);
|
|
5695
|
+
if (runnerEx) {
|
|
5714
5696
|
/**
|
|
5715
|
-
*
|
|
5697
|
+
* Stop any active telemetry/instrument publishing for this runner.
|
|
5698
|
+
*
|
|
5699
|
+
* This is done before archive/delete handling so no further
|
|
5700
|
+
* publishing occurs after the runner is considered retired.
|
|
5716
5701
|
*/
|
|
5717
|
-
if (
|
|
5718
|
-
|
|
5719
|
-
|
|
5720
|
-
|
|
5721
|
-
* to the archive list. This prevents the runner from being
|
|
5722
|
-
* reprocessed on future scans.
|
|
5723
|
-
*/
|
|
5724
|
-
runnerEx.archived = true;
|
|
5725
|
-
/**
|
|
5726
|
-
* Schedule deletion of the live runner instance from the worker registry.
|
|
5727
|
-
*
|
|
5728
|
-
* This removes the runner from the active runtime graph after a delay.
|
|
5729
|
-
*/
|
|
5730
|
-
if (this.archiveDeleteTimeout !== 0) {
|
|
5731
|
-
const timeout = setTimeout(() => this.options.workerRegistry.DeleteRunner(workerEx.id, removeList[i].runnerId), this.archiveDeleteTimeout * 1e3);
|
|
5702
|
+
if (runnerEx.publishInstrumentController) {
|
|
5703
|
+
this.options.logger.debug(import_source.default.grey(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5704
|
+
runnerEx.publishInstrumentController.EndPublish();
|
|
5705
|
+
}
|
|
5732
5706
|
/**
|
|
5733
|
-
*
|
|
5707
|
+
* Only non-terminated runners are stored in the archive list.
|
|
5708
|
+
*
|
|
5709
|
+
* Terminated runners are treated as retired/removed but not archived.
|
|
5734
5710
|
*/
|
|
5735
|
-
if (
|
|
5711
|
+
if (runnerEx.state !== IRunnerState.terminated) {
|
|
5712
|
+
this.options.logger.debug(import_source.default.grey(`Archive runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5713
|
+
const runner = runnerEx.toRunner();
|
|
5714
|
+
this.archiveList.push(runner);
|
|
5715
|
+
/**
|
|
5716
|
+
* Enforce archive list size cap by discarding the oldest item.
|
|
5717
|
+
*/
|
|
5718
|
+
if (this.archiveList.length > this.options.maxArchiveListLength) this.archiveList.shift();
|
|
5719
|
+
} else this.options.logger.debug(import_source.default.grey(`Runner has been terminated and will not be archived, runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5720
|
+
/**
|
|
5721
|
+
* Mark as archived regardless of whether it was actually added
|
|
5722
|
+
* to the archive list. This prevents the runner from being
|
|
5723
|
+
* reprocessed on future scans.
|
|
5724
|
+
*/
|
|
5725
|
+
runnerEx.archived = true;
|
|
5726
|
+
/**
|
|
5727
|
+
* Schedule deletion of the live runner instance from the worker registry.
|
|
5728
|
+
*
|
|
5729
|
+
* This removes the runner from the active runtime graph after a delay.
|
|
5730
|
+
*/
|
|
5731
|
+
if (this.archiveDeleteTimeout !== 0) {
|
|
5732
|
+
const archiveDelTimeout = setTimeout(() => {
|
|
5733
|
+
try {
|
|
5734
|
+
this.options.workerRegistry.DeleteRunner(workerEx.id, removeList[i].runnerId);
|
|
5735
|
+
} catch (error) {
|
|
5736
|
+
this.options.logger.error(`Error in: this.options.workerRegistry.DeleteRunner(${workerEx.id}, ${removeList[i].runnerId})`);
|
|
5737
|
+
}
|
|
5738
|
+
}, this.archiveDeleteTimeout * 1e3);
|
|
5739
|
+
/**
|
|
5740
|
+
* In Node.js, unref the timer so it does not keep the process alive.
|
|
5741
|
+
*/
|
|
5742
|
+
if (import_browser.default) archiveDelTimeout.unref();
|
|
5743
|
+
}
|
|
5736
5744
|
}
|
|
5737
5745
|
}
|
|
5738
5746
|
}
|
|
5739
|
-
|
|
5740
|
-
|
|
5741
|
-
|
|
5742
|
-
|
|
5743
|
-
|
|
5744
|
-
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
+
/**
|
|
5748
|
+
* Emit a debug summary showing remaining live runner counts per worker.
|
|
5749
|
+
*/
|
|
5750
|
+
for (const [, workerEx] of Object.entries(this.options.workerRegistry.GetWorkersEx([]))) {
|
|
5751
|
+
const message = `STSWorkerManager:_processLoopExecutor(): Remaining runners from worker: [${workerEx.id}]: [${workerEx.GetAllRunnersEx().length}]`;
|
|
5752
|
+
this.options.logger.debug(import_source.default.magenta(message));
|
|
5753
|
+
}
|
|
5754
|
+
/**
|
|
5755
|
+
* Schedule the next archive scan.
|
|
5756
|
+
*/
|
|
5757
|
+
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5758
|
+
if (import_browser.default) this.timeout.unref();
|
|
5759
|
+
}, 100);
|
|
5760
|
+
if (import_browser.default) startTimeout.unref();
|
|
5761
|
+
} else {
|
|
5747
5762
|
/**
|
|
5748
|
-
*
|
|
5763
|
+
* No archive candidates found; just schedule the next scan.
|
|
5749
5764
|
*/
|
|
5750
5765
|
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5751
|
-
|
|
5752
|
-
|
|
5753
|
-
/**
|
|
5754
|
-
* No archive candidates found; just schedule the next scan.
|
|
5755
|
-
*/
|
|
5756
|
-
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5766
|
+
if (import_browser.default) this.timeout.unref();
|
|
5767
|
+
}
|
|
5757
5768
|
} catch (error) {
|
|
5758
5769
|
this.options.logger.error(`_processLoopExecutor(): Error: [${error}]`);
|
|
5759
5770
|
throw error;
|
|
@@ -5806,7 +5817,11 @@ var ArchiveManager = class {
|
|
|
5806
5817
|
* - called during overall worker-manager shutdown/termination
|
|
5807
5818
|
*/
|
|
5808
5819
|
Terminate = () => {
|
|
5809
|
-
|
|
5820
|
+
this.options.logger.debug(`ArchiveManager:Terminate()`);
|
|
5821
|
+
if (this.timeout) {
|
|
5822
|
+
this.options.logger.debug(`ArchiveManager:Terminate() - this.timeout cleared ...`);
|
|
5823
|
+
clearTimeout(this.timeout);
|
|
5824
|
+
}
|
|
5810
5825
|
};
|
|
5811
5826
|
};
|
|
5812
5827
|
//#endregion
|
|
@@ -8236,6 +8251,7 @@ var STSWorkerManager = class {
|
|
|
8236
8251
|
* - callers should explicitly terminate workers first if desired
|
|
8237
8252
|
*/
|
|
8238
8253
|
Terminate() {
|
|
8254
|
+
this.options.logger.debug(`STSWorkerManager:Terminate()`);
|
|
8239
8255
|
this.#archiveManager.Terminate();
|
|
8240
8256
|
}
|
|
8241
8257
|
/**
|