@nsshunt/stsrunnerframework 1.0.5 → 1.0.7
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.
|
@@ -17,7 +17,7 @@ var __privateWrapper = (obj, member, setter, getter) => ({
|
|
|
17
17
|
return __privateGet(obj, member, getter);
|
|
18
18
|
}
|
|
19
19
|
});
|
|
20
|
-
var _collectorCollectorPort, _runners, _options, _debug, _SetMessagePort, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _StartRunner, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _runner, _workerId, _options2, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2,
|
|
20
|
+
var _collectorCollectorPort, _runners, _options, _debug, _SetMessagePort, _AddRunner, _WorkerInstance_instances, SleepImmediate_fn, _StartRunner, _StopAllRunners, _StopRunner, _TerminateRunner, _PauseRunner, _ResumeRunner, _ResetRunner, _ExecuteRunner, _UpdateOptions, _workersEx, _runner, _workerId, _options2, _STSInstrumentController, _telemetryProcessor, _debug2, _STSWorkerManager_instances, CreateRunnerCopy_fn, _SetRunnerIntoWorker, _ProcessTelemetry, _ProcessCompleted, _CreateAsyncRunner, _PostMessageToWorker, _StartRunner2, _ResetRunner2, _ExecuteRunner2, _StopRunner2, _TerminateRunner2, _PauseRunner2, _ResumeRunner2, _BroadcastCommandToAllRunners, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
|
|
21
21
|
import { Sleep, ModelDelimeter } from "@nsshunt/stsutils";
|
|
22
22
|
import { Gauge } from "@nsshunt/stsobservability";
|
|
23
23
|
const URI_BASE_VUEUTILS = "/";
|
|
@@ -1945,6 +1945,12 @@ class STSWorkerManager {
|
|
|
1945
1945
|
publishMessagePayload = data;
|
|
1946
1946
|
processMessage(publishMessagePayload);
|
|
1947
1947
|
});
|
|
1948
|
+
workerPort.on("exit", (code) => {
|
|
1949
|
+
console.log(chalk$1.magenta(`Worker exited with code: ${code}`));
|
|
1950
|
+
});
|
|
1951
|
+
workerPort.on("error", (error) => {
|
|
1952
|
+
console.log(chalk$1.red(`Worker error: ${error}`));
|
|
1953
|
+
});
|
|
1948
1954
|
} else {
|
|
1949
1955
|
workerPort.onmessage = async (data) => {
|
|
1950
1956
|
publishMessagePayload = data.data;
|
|
@@ -2091,28 +2097,35 @@ class STSWorkerManager {
|
|
|
2091
2097
|
return true;
|
|
2092
2098
|
});
|
|
2093
2099
|
__privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx = null) => {
|
|
2094
|
-
|
|
2095
|
-
|
|
2096
|
-
|
|
2097
|
-
|
|
2098
|
-
|
|
2100
|
+
return new Promise((resolve, reject) => {
|
|
2101
|
+
if (runnerEx === null) {
|
|
2102
|
+
const ids = Object.keys(workerEx.runnersEx);
|
|
2103
|
+
if (ids.length > 0) {
|
|
2104
|
+
const id = ids[0];
|
|
2105
|
+
runnerEx = workerEx.runnersEx[id];
|
|
2106
|
+
}
|
|
2099
2107
|
}
|
|
2100
|
-
|
|
2101
|
-
|
|
2102
|
-
|
|
2103
|
-
|
|
2104
|
-
|
|
2105
|
-
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
|
|
2109
|
-
|
|
2110
|
-
|
|
2111
|
-
|
|
2112
|
-
|
|
2113
|
-
|
|
2114
|
-
|
|
2115
|
-
|
|
2108
|
+
if (runnerEx !== null) {
|
|
2109
|
+
(async () => {
|
|
2110
|
+
console.log(chalk$1.magenta(`Sending message to terminate runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
2111
|
+
__privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
|
|
2112
|
+
runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
|
|
2113
|
+
});
|
|
2114
|
+
runnerEx.publishInstrumentController.LogEx(`Terminating runner: [${runnerEx.id}]`);
|
|
2115
|
+
await Sleep(2e3);
|
|
2116
|
+
console.log(chalk$1.magenta(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
2117
|
+
await runnerEx.publishInstrumentController.EndPublish();
|
|
2118
|
+
await Sleep(2e3);
|
|
2119
|
+
console.log(chalk$1.magenta(`Ending publish for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
2120
|
+
delete workerEx.runnersEx[runnerEx.id];
|
|
2121
|
+
console.log(chalk$1.magenta(`Completed Terminate for runner: [${JSON.stringify(runnerEx.asyncRunnerContext)}]`));
|
|
2122
|
+
resolve(true);
|
|
2123
|
+
})();
|
|
2124
|
+
} else {
|
|
2125
|
+
console.log(chalk$1.magenta(`No runner to terminate.`));
|
|
2126
|
+
resolve(false);
|
|
2127
|
+
}
|
|
2128
|
+
});
|
|
2116
2129
|
});
|
|
2117
2130
|
__privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
|
|
2118
2131
|
__privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
|
|
@@ -2126,10 +2139,9 @@ class STSWorkerManager {
|
|
|
2126
2139
|
});
|
|
2127
2140
|
return true;
|
|
2128
2141
|
});
|
|
2129
|
-
__privateAdd(this,
|
|
2142
|
+
__privateAdd(this, _BroadcastCommandToAllRunners, async (workerEx, command, options) => {
|
|
2130
2143
|
try {
|
|
2131
2144
|
if (workerEx.state !== IWorkerState.stopped) {
|
|
2132
|
-
console.log(`Stop Worker: [${workerEx.id}]`);
|
|
2133
2145
|
const promArray = [];
|
|
2134
2146
|
const ids = Object.keys(workerEx.runnersEx);
|
|
2135
2147
|
ids.forEach((id) => {
|
|
@@ -2149,30 +2161,30 @@ class STSWorkerManager {
|
|
|
2149
2161
|
}
|
|
2150
2162
|
});
|
|
2151
2163
|
__privateAdd(this, _PauseWorker, async (workerEx) => {
|
|
2152
|
-
return __privateGet(this,
|
|
2164
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _PauseRunner2));
|
|
2153
2165
|
});
|
|
2154
2166
|
__privateAdd(this, _ResumeWorker, async (workerEx) => {
|
|
2155
|
-
return __privateGet(this,
|
|
2167
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _ResumeRunner2));
|
|
2156
2168
|
});
|
|
2157
2169
|
__privateAdd(this, _StopWorker, async (workerEx) => {
|
|
2158
|
-
return __privateGet(this,
|
|
2170
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _StopRunner2));
|
|
2159
2171
|
});
|
|
2160
2172
|
__privateAdd(this, _StartWorker, async (workerEx) => {
|
|
2161
|
-
return __privateGet(this,
|
|
2173
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _StartRunner2));
|
|
2162
2174
|
});
|
|
2163
2175
|
__privateAdd(this, _ResetWorker, async (workerEx) => {
|
|
2164
|
-
return __privateGet(this,
|
|
2176
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _ResetRunner2));
|
|
2165
2177
|
});
|
|
2166
2178
|
__privateAdd(this, _ExecuteWorker, async (workerEx) => {
|
|
2167
|
-
return __privateGet(this,
|
|
2179
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _ExecuteRunner2));
|
|
2168
2180
|
});
|
|
2169
2181
|
__privateAdd(this, _UpdateOptionsWorker, async (workerEx, options) => {
|
|
2170
|
-
return __privateGet(this,
|
|
2182
|
+
return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _UpdateOptions2), options);
|
|
2171
2183
|
});
|
|
2172
2184
|
__privateAdd(this, _TerminateWorker, async (workerEx) => {
|
|
2173
2185
|
try {
|
|
2174
2186
|
if (workerEx.state !== IWorkerState.stopped) {
|
|
2175
|
-
await __privateGet(this,
|
|
2187
|
+
await __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
|
|
2176
2188
|
if (workerEx.worker) {
|
|
2177
2189
|
workerEx.worker.terminate();
|
|
2178
2190
|
__privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
|
|
@@ -2278,7 +2290,7 @@ _StopRunner2 = new WeakMap();
|
|
|
2278
2290
|
_TerminateRunner2 = new WeakMap();
|
|
2279
2291
|
_PauseRunner2 = new WeakMap();
|
|
2280
2292
|
_ResumeRunner2 = new WeakMap();
|
|
2281
|
-
|
|
2293
|
+
_BroadcastCommandToAllRunners = new WeakMap();
|
|
2282
2294
|
_PauseWorker = new WeakMap();
|
|
2283
2295
|
_ResumeWorker = new WeakMap();
|
|
2284
2296
|
_StopWorker = new WeakMap();
|