You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openwhisk.apache.org by al...@apache.org on 2020/03/31 18:27:06 UTC
[openwhisk-wskdebug] 07/07: fix duplicated shutdown() issue on
CTRL+C
This is an automated email from the ASF dual-hosted git repository.
alexkli pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/openwhisk-wskdebug.git
commit 397aa85b1c1465116b9edcd0c791610c2f19fa39
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Tue Mar 31 00:33:36 2020 -0700
fix duplicated shutdown() issue on CTRL+C
---
src/agentmgr.js | 2 --
src/debugger.js | 11 +++++++++--
2 files changed, 9 insertions(+), 4 deletions(-)
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 @@ async function deleteActionIfExists(wsk, name) {
}
-// 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 @@ class Debugger {
async _run() {
try {
this.running = true;
+ this.shuttingDown = false;
// main blocking loop
// abort if this.running is set to false
@@ -132,7 +133,6 @@ class Debugger {
// wait for activation, run it, complete, repeat
const activation = await this.agentMgr.waitForActivations();
if (!activation) {
- // this.running = false;
return;
}
@@ -149,7 +149,6 @@ class Debugger {
// 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 @@ class Debugger {
}
}
+ // normal graceful stop() initiated by a client
async stop() {
this.running = false;
if (this.agentMgr) {
@@ -174,6 +174,7 @@ class Debugger {
}
}
+ // fastest way to end, triggered by CTRL+C
async kill() {
this.running = false;
if (this.agentMgr) {
@@ -184,6 +185,12 @@ class Debugger {
}
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();