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/04/14 07:53:34 UTC
[openwhisk-wskdebug] 04/09: performance: create backup action in
parallel when debugger is already ready
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 ef712b8eb808f918e94e541376f67ea4f91b19e9
Author: Alexander Klimetschek <ak...@adobe.com>
AuthorDate: Mon Apr 13 18:49:30 2020 -0700
performance: create backup action in parallel when debugger is already ready
saves many seconds on startup with larger actions
---
src/agentmgr.js | 20 +++++++++++++-------
1 file changed, 13 insertions(+), 7 deletions(-)
diff --git a/src/agentmgr.js b/src/agentmgr.js
index d862e05..452e49a 100644
--- a/src/agentmgr.js
+++ b/src/agentmgr.js
@@ -213,15 +213,18 @@ class AgentMgr {
console.log(`Installing agent in OpenWhisk (${agentName})...`);
}
- // create copy
- await this.wsk.actions.update({
- name: backupName,
- action: agentAction
- });
- debug(`created action backup ${backupName}`);
+ // create copy in case wskdebug gets killed hard
+ // do async as this can be slow for larger actions and this is part of the critical startup path
+ this.createBackup = (async () => {
+ await this.wsk.actions.update({
+ name: backupName,
+ action: agentAction
+ });
+ debug(`created action backup ${backupName}`);
+ })();
if (this.argv.verbose) {
- console.log(`Original action backed up at ${backupName}.`);
+ console.log(`Original action will be backed up at ${backupName}.`);
}
if (this.argv.condition) {
@@ -255,6 +258,9 @@ class AgentMgr {
async shutdown() {
try {
+ // make sure we finished creating the backup
+ await this.createBackup;
+
if (this.agentInstalled) {
await this.restoreAction();
}