fix duplicated shutdown() issue on CTRL+C
diff --git a/src/agentmgr.js b/src/agentmgr.js
index 8753f41..8b59f28 100644
--- a/src/agentmgr.js
+++ b/src/agentmgr.js
@@ -72,8 +72,6 @@
}
-// TODO: test wskdebug manually
-// TODO: openwhiskSupports() into separate shared class
class AgentMgr {
constructor(argv, wsk, actionName) {
diff --git a/src/debugger.js b/src/debugger.js
index 415bde9..8cf08fb 100644
--- a/src/debugger.js
+++ b/src/debugger.js
@@ -116,6 +116,7 @@
async _run() {
try {
this.running = true;
+ this.shuttingDown = false;
// main blocking loop
// abort if this.running is set to false
@@ -132,7 +133,6 @@
// wait for activation, run it, complete, repeat
const activation = await this.agentMgr.waitForActivations();
if (!activation) {
- // this.running = false;
return;
}
@@ -149,7 +149,6 @@
// pass on the local result to the agent in openwhisk
if (!await this.agentMgr.completeActivation(id, result, duration)) {
- // this.running = false;
return;
}
}
@@ -159,6 +158,7 @@
}
}
+ // normal graceful stop() initiated by a client
async stop() {
this.running = false;
if (this.agentMgr) {
@@ -174,6 +174,7 @@
}
}
+ // fastest way to end, triggered by CTRL+C
async kill() {
this.running = false;
if (this.agentMgr) {
@@ -184,6 +185,12 @@
}
async shutdown() {
+ // avoid duplicate shutdown on CTRL+C
+ if (this.shuttingDown) {
+ return;
+ }
+ this.shuttingDown = true;
+
// only log this if we started properly
if (this.ready) {
console.log();