diff --git a/README.md b/README.md index c840856..e459f00 100644 --- a/README.md +++ b/README.md @@ -14,6 +14,9 @@ Set process.env.JS_CONTROLLER_VERSION to version e.g. `5.0.5-alpha.0-20230617-46 ## Changelog +### **WORK IN PROGRESS** +* (bluefox) Added support for the once mode + ### 1.0.10 (2024-04-10) * (bluefox) Added support for vis-2 testing diff --git a/setup.js b/setup.js index 51dff58..b5050c9 100644 --- a/setup.js +++ b/setup.js @@ -711,6 +711,27 @@ function startCustomAdapter(adapterName, adapterInstance) { stdio: [0, 1, 2, 'ipc'], }); } + pids[id].on('exit', (code, signal) => { + if (pids[id]) { + console.log(`child process terminated 1 due to receipt of signal ${signal}`); + let resolve = pids[id].customResolve; + if (resolve) { + delete pids[id].customResolve; + } + pids[id] = null; + resolve && resolve(); + } + }); + pids[id].on('close', () => { + if (pids[id]) { + let resolve = pids[id].customResolve; + if (resolve) { + delete pids[id].customResolve; + } + pids[id] = null; + resolve && resolve(); + } + }); } catch (error) { console.error(JSON.stringify(error)); } @@ -853,16 +874,19 @@ function stopCustomAdapter(adapterName, adapterInstance) { } else { adaptersStarted[id] = false; return new Promise(resolve => { + pids[id].customResolve = resolve; pids[id].on('exit', (code, signal) => { if (pids[id]) { - console.log(`child process terminated due to receipt of signal ${signal}`); + console.log(`child process terminated 3 due to receipt of signal ${signal}`); + delete pids[id].customResolve; pids[id] = null; resolve(); } }); - pids[id].on('close', (/* code, signal */) => { + pids[id].on('close', () => { if (pids[id]) { + delete pids[id].customResolve; pids[id] = null; resolve(); }