@nsshunt/stsrunnerframework 1.0.6 → 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, _WorkerCommand, _PauseWorker, _ResumeWorker, _StopWorker, _StartWorker, _ResetWorker, _ExecuteWorker, _UpdateOptionsWorker, _TerminateWorker, _UpdateOptions2;
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 = "/";
@@ -2097,28 +2097,35 @@ class STSWorkerManager {
2097
2097
  return true;
2098
2098
  });
2099
2099
  __privateAdd(this, _TerminateRunner2, async (workerEx, runnerEx = null) => {
2100
- if (runnerEx === null) {
2101
- const ids = Object.keys(workerEx.runnersEx);
2102
- if (ids.length > 0) {
2103
- const id = ids[0];
2104
- runnerEx = workerEx.runnersEx[id];
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
+ }
2105
2107
  }
2106
- }
2107
- if (runnerEx !== null) {
2108
- __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.TerminateRunner, {
2109
- runner: __privateMethod(this, _STSWorkerManager_instances, CreateRunnerCopy_fn).call(this, runnerEx)
2110
- });
2111
- runnerEx.publishInstrumentController.LogEx(`Terminating runner: [${runnerEx.id}]`);
2112
- const promArray = [];
2113
- promArray.push((async () => {
2114
- await Sleep(100);
2115
- return runnerEx.publishInstrumentController.EndPublish();
2116
- })());
2117
- delete workerEx.runnersEx[runnerEx.id];
2118
- const retVal = await Promise.all(promArray);
2119
- console.log(`Removed instrument workers: [${retVal}]`);
2120
- }
2121
- return true;
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
+ });
2122
2129
  });
2123
2130
  __privateAdd(this, _PauseRunner2, async (workerEx, runnerEx) => {
2124
2131
  __privateGet(this, _PostMessageToWorker).call(this, workerEx, eIWMessageCommands.PauseRunner, {
@@ -2132,10 +2139,9 @@ class STSWorkerManager {
2132
2139
  });
2133
2140
  return true;
2134
2141
  });
2135
- __privateAdd(this, _WorkerCommand, async (workerEx, command, options) => {
2142
+ __privateAdd(this, _BroadcastCommandToAllRunners, async (workerEx, command, options) => {
2136
2143
  try {
2137
2144
  if (workerEx.state !== IWorkerState.stopped) {
2138
- console.log(`Stop Worker: [${workerEx.id}]`);
2139
2145
  const promArray = [];
2140
2146
  const ids = Object.keys(workerEx.runnersEx);
2141
2147
  ids.forEach((id) => {
@@ -2155,30 +2161,30 @@ class STSWorkerManager {
2155
2161
  }
2156
2162
  });
2157
2163
  __privateAdd(this, _PauseWorker, async (workerEx) => {
2158
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _PauseRunner2));
2164
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _PauseRunner2));
2159
2165
  });
2160
2166
  __privateAdd(this, _ResumeWorker, async (workerEx) => {
2161
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _ResumeRunner2));
2167
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _ResumeRunner2));
2162
2168
  });
2163
2169
  __privateAdd(this, _StopWorker, async (workerEx) => {
2164
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _StopRunner2));
2170
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _StopRunner2));
2165
2171
  });
2166
2172
  __privateAdd(this, _StartWorker, async (workerEx) => {
2167
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _StartRunner2));
2173
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _StartRunner2));
2168
2174
  });
2169
2175
  __privateAdd(this, _ResetWorker, async (workerEx) => {
2170
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _ResetRunner2));
2176
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _ResetRunner2));
2171
2177
  });
2172
2178
  __privateAdd(this, _ExecuteWorker, async (workerEx) => {
2173
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _ExecuteRunner2));
2179
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _ExecuteRunner2));
2174
2180
  });
2175
2181
  __privateAdd(this, _UpdateOptionsWorker, async (workerEx, options) => {
2176
- return __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _UpdateOptions2), options);
2182
+ return __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _UpdateOptions2), options);
2177
2183
  });
2178
2184
  __privateAdd(this, _TerminateWorker, async (workerEx) => {
2179
2185
  try {
2180
2186
  if (workerEx.state !== IWorkerState.stopped) {
2181
- await __privateGet(this, _WorkerCommand).call(this, workerEx, __privateGet(this, _TerminateRunner2));
2187
+ await __privateGet(this, _BroadcastCommandToAllRunners).call(this, workerEx, __privateGet(this, _TerminateRunner2));
2182
2188
  if (workerEx.worker) {
2183
2189
  workerEx.worker.terminate();
2184
2190
  __privateGet(this, _debug2).call(this, `Terminated worker: [${workerEx.id}]`);
@@ -2284,7 +2290,7 @@ _StopRunner2 = new WeakMap();
2284
2290
  _TerminateRunner2 = new WeakMap();
2285
2291
  _PauseRunner2 = new WeakMap();
2286
2292
  _ResumeRunner2 = new WeakMap();
2287
- _WorkerCommand = new WeakMap();
2293
+ _BroadcastCommandToAllRunners = new WeakMap();
2288
2294
  _PauseWorker = new WeakMap();
2289
2295
  _ResumeWorker = new WeakMap();
2290
2296
  _StopWorker = new WeakMap();