@nsshunt/stsrunnerframework 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/dist/stsrunnerframework.mjs +84 -63
- package/dist/stsrunnerframework.mjs.map +1 -1
- package/dist/stsrunnerframework.umd.js +84 -63
- package/dist/stsrunnerframework.umd.js.map +1 -1
- package/package.json +1 -1
- package/types/archiveManager.d.ts +1 -0
- package/types/archiveManager.d.ts.map +1 -1
- package/types/workerManager.d.ts.map +1 -1
|
@@ -5618,6 +5618,7 @@ ${runnerId}`,
|
|
|
5618
5618
|
* This is stored so the loop can be stopped later via {@link Terminate}.
|
|
5619
5619
|
*/
|
|
5620
5620
|
timeout;
|
|
5621
|
+
archiveDelTimeout;
|
|
5621
5622
|
/**
|
|
5622
5623
|
* Construct a new archive manager.
|
|
5623
5624
|
*
|
|
@@ -5688,78 +5689,89 @@ ${runnerId}`,
|
|
|
5688
5689
|
* If matching runners were found, process them after a short delay.
|
|
5689
5690
|
* Otherwise just schedule the next scan loop.
|
|
5690
5691
|
*/
|
|
5691
|
-
if (removeList.length > 0)
|
|
5692
|
-
|
|
5693
|
-
|
|
5694
|
-
|
|
5695
|
-
|
|
5696
|
-
|
|
5697
|
-
|
|
5698
|
-
|
|
5699
|
-
|
|
5700
|
-
|
|
5701
|
-
|
|
5702
|
-
* Stop any active telemetry/instrument publishing for this runner.
|
|
5703
|
-
*
|
|
5704
|
-
* This is done before archive/delete handling so no further
|
|
5705
|
-
* publishing occurs after the runner is considered retired.
|
|
5706
|
-
*/
|
|
5707
|
-
if (runnerEx.publishInstrumentController) {
|
|
5708
|
-
this.options.logger.debug(import_source.default.grey(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5709
|
-
runnerEx.publishInstrumentController.EndPublish();
|
|
5710
|
-
}
|
|
5711
|
-
/**
|
|
5712
|
-
* Only non-terminated runners are stored in the archive list.
|
|
5713
|
-
*
|
|
5714
|
-
* Terminated runners are treated as retired/removed but not archived.
|
|
5715
|
-
*/
|
|
5716
|
-
if (runnerEx.state !== IRunnerState.terminated) {
|
|
5717
|
-
this.options.logger.debug(import_source.default.grey(`Archive runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5718
|
-
const runner = runnerEx.toRunner();
|
|
5719
|
-
this.archiveList.push(runner);
|
|
5692
|
+
if (removeList.length > 0) {
|
|
5693
|
+
const startTimeout = setTimeout(async () => {
|
|
5694
|
+
this.options.logger.debug(import_source.default.grey(`STSWorkerManager:_processLoopExecutor(): Removing runners from collection: [${JSON.stringify(removeList)}]`));
|
|
5695
|
+
/**
|
|
5696
|
+
* Process each matched runner from the temporary remove list.
|
|
5697
|
+
*/
|
|
5698
|
+
for (let i = 0; i < removeList.length; i++) {
|
|
5699
|
+
const workerEx = this.options.workerRegistry.GetWorkerEx(removeList[i].workerId);
|
|
5700
|
+
if (workerEx) {
|
|
5701
|
+
const runnerEx = workerEx.GetRunnerEx(removeList[i].runnerId);
|
|
5702
|
+
if (runnerEx) {
|
|
5720
5703
|
/**
|
|
5721
|
-
*
|
|
5704
|
+
* Stop any active telemetry/instrument publishing for this runner.
|
|
5705
|
+
*
|
|
5706
|
+
* This is done before archive/delete handling so no further
|
|
5707
|
+
* publishing occurs after the runner is considered retired.
|
|
5722
5708
|
*/
|
|
5723
|
-
if (
|
|
5724
|
-
|
|
5725
|
-
|
|
5726
|
-
|
|
5727
|
-
* to the archive list. This prevents the runner from being
|
|
5728
|
-
* reprocessed on future scans.
|
|
5729
|
-
*/
|
|
5730
|
-
runnerEx.archived = true;
|
|
5731
|
-
/**
|
|
5732
|
-
* Schedule deletion of the live runner instance from the worker registry.
|
|
5733
|
-
*
|
|
5734
|
-
* This removes the runner from the active runtime graph after a delay.
|
|
5735
|
-
*/
|
|
5736
|
-
if (this.archiveDeleteTimeout !== 0) {
|
|
5737
|
-
const timeout = setTimeout(() => this.options.workerRegistry.DeleteRunner(workerEx.id, removeList[i].runnerId), this.archiveDeleteTimeout * 1e3);
|
|
5709
|
+
if (runnerEx.publishInstrumentController) {
|
|
5710
|
+
this.options.logger.debug(import_source.default.grey(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5711
|
+
runnerEx.publishInstrumentController.EndPublish();
|
|
5712
|
+
}
|
|
5738
5713
|
/**
|
|
5739
|
-
*
|
|
5714
|
+
* Only non-terminated runners are stored in the archive list.
|
|
5715
|
+
*
|
|
5716
|
+
* Terminated runners are treated as retired/removed but not archived.
|
|
5740
5717
|
*/
|
|
5741
|
-
if (
|
|
5718
|
+
if (runnerEx.state !== IRunnerState.terminated) {
|
|
5719
|
+
this.options.logger.debug(import_source.default.grey(`Archive runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5720
|
+
const runner = runnerEx.toRunner();
|
|
5721
|
+
this.archiveList.push(runner);
|
|
5722
|
+
/**
|
|
5723
|
+
* Enforce archive list size cap by discarding the oldest item.
|
|
5724
|
+
*/
|
|
5725
|
+
if (this.archiveList.length > this.options.maxArchiveListLength) this.archiveList.shift();
|
|
5726
|
+
} else this.options.logger.debug(import_source.default.grey(`Runner has been terminated and will not be archived, runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
5727
|
+
/**
|
|
5728
|
+
* Mark as archived regardless of whether it was actually added
|
|
5729
|
+
* to the archive list. This prevents the runner from being
|
|
5730
|
+
* reprocessed on future scans.
|
|
5731
|
+
*/
|
|
5732
|
+
runnerEx.archived = true;
|
|
5733
|
+
/**
|
|
5734
|
+
* Schedule deletion of the live runner instance from the worker registry.
|
|
5735
|
+
*
|
|
5736
|
+
* This removes the runner from the active runtime graph after a delay.
|
|
5737
|
+
*/
|
|
5738
|
+
if (this.archiveDeleteTimeout !== 0) {
|
|
5739
|
+
this.archiveDelTimeout = setTimeout(() => {
|
|
5740
|
+
try {
|
|
5741
|
+
this.options.workerRegistry.DeleteRunner(workerEx.id, removeList[i].runnerId);
|
|
5742
|
+
} catch (error) {
|
|
5743
|
+
this.options.logger.error(`Error in: this.options.workerRegistry.DeleteRunner(${workerEx.id}, ${removeList[i].runnerId})`);
|
|
5744
|
+
}
|
|
5745
|
+
}, this.archiveDeleteTimeout * 1e3);
|
|
5746
|
+
/**
|
|
5747
|
+
* In Node.js, unref the timer so it does not keep the process alive.
|
|
5748
|
+
*/
|
|
5749
|
+
if (import_browser.default) this.archiveDelTimeout.unref();
|
|
5750
|
+
}
|
|
5742
5751
|
}
|
|
5743
5752
|
}
|
|
5744
5753
|
}
|
|
5745
|
-
|
|
5746
|
-
|
|
5747
|
-
|
|
5748
|
-
|
|
5749
|
-
|
|
5750
|
-
|
|
5751
|
-
|
|
5752
|
-
|
|
5754
|
+
/**
|
|
5755
|
+
* Emit a debug summary showing remaining live runner counts per worker.
|
|
5756
|
+
*/
|
|
5757
|
+
for (const [, workerEx] of Object.entries(this.options.workerRegistry.GetWorkersEx([]))) {
|
|
5758
|
+
const message = `STSWorkerManager:_processLoopExecutor(): Remaining runners from worker: [${workerEx.id}]: [${workerEx.GetAllRunnersEx().length}]`;
|
|
5759
|
+
this.options.logger.debug(import_source.default.magenta(message));
|
|
5760
|
+
}
|
|
5761
|
+
/**
|
|
5762
|
+
* Schedule the next archive scan.
|
|
5763
|
+
*/
|
|
5764
|
+
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5765
|
+
if (import_browser.default) this.timeout.unref();
|
|
5766
|
+
}, 100);
|
|
5767
|
+
if (import_browser.default) startTimeout.unref();
|
|
5768
|
+
} else {
|
|
5753
5769
|
/**
|
|
5754
|
-
*
|
|
5770
|
+
* No archive candidates found; just schedule the next scan.
|
|
5755
5771
|
*/
|
|
5756
5772
|
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5757
|
-
|
|
5758
|
-
|
|
5759
|
-
/**
|
|
5760
|
-
* No archive candidates found; just schedule the next scan.
|
|
5761
|
-
*/
|
|
5762
|
-
this.timeout = setTimeout(() => this.ProcessLoopExecutor(), 1e3);
|
|
5773
|
+
if (import_browser.default) this.timeout.unref();
|
|
5774
|
+
}
|
|
5763
5775
|
} catch (error) {
|
|
5764
5776
|
this.options.logger.error(`_processLoopExecutor(): Error: [${error}]`);
|
|
5765
5777
|
throw error;
|
|
@@ -5812,7 +5824,15 @@ ${runnerId}`,
|
|
|
5812
5824
|
* - called during overall worker-manager shutdown/termination
|
|
5813
5825
|
*/
|
|
5814
5826
|
Terminate = () => {
|
|
5815
|
-
|
|
5827
|
+
this.options.logger.debug(`ArchiveManager:Terminate()`);
|
|
5828
|
+
if (this.timeout) {
|
|
5829
|
+
this.options.logger.debug(`ArchiveManager:Terminate() - this.timeout cleared ...`);
|
|
5830
|
+
clearTimeout(this.timeout);
|
|
5831
|
+
}
|
|
5832
|
+
if (this.archiveDelTimeout) {
|
|
5833
|
+
this.options.logger.debug(`ArchiveManager:Terminate() - this.archiveDelTimeout cleared ...`);
|
|
5834
|
+
clearTimeout(this.archiveDelTimeout);
|
|
5835
|
+
}
|
|
5816
5836
|
};
|
|
5817
5837
|
};
|
|
5818
5838
|
//#endregion
|
|
@@ -8242,6 +8262,7 @@ ${runnerId}`,
|
|
|
8242
8262
|
* - callers should explicitly terminate workers first if desired
|
|
8243
8263
|
*/
|
|
8244
8264
|
Terminate() {
|
|
8265
|
+
this.options.logger.debug(`STSWorkerManager:Terminate()`);
|
|
8245
8266
|
this.#archiveManager.Terminate();
|
|
8246
8267
|
}
|
|
8247
8268
|
/**
|