From 188a68826439a7c7e001be192637afa5cef25fda Mon Sep 17 00:00:00 2001 From: Pascal Precht Date: Thu, 11 Oct 2018 12:21:26 +0200 Subject: [PATCH] refactor(modules/ipfs): use ProcessManager APIs to register and launch IPFS process ProcessManager can be used to "register" processes and along with it, a launch function that will be executed when a process is requested to launch. Prior to this commit the IPFS process has not be registered and launching the process was done manually, bypassing ProcessManager APIs. With this commit we take advantage of ProcessManager APIs to register the IPFS process and launch it using the `process:launch` event. --- lib/modules/ipfs/index.js | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/modules/ipfs/index.js b/lib/modules/ipfs/index.js index 4ed8c6ab5..a70bafd95 100644 --- a/lib/modules/ipfs/index.js +++ b/lib/modules/ipfs/index.js @@ -26,6 +26,10 @@ class IPFS { this.addObjectToConsole(); this.registerUploadCommand(); + this.events.request("processes:register", "ipfs", (cb) => { + self.startProcess(cb); + }); + this._checkService((err) => { if (!err) { return; @@ -33,8 +37,7 @@ class IPFS { self.logger.info("IPFS node not found, attempting to start own node"); this.listenToCommands(); this.registerConsoleCommands(); - self.startProcess(() => {}); - this.events.request("processes:launch", "ipfs", () => {}); + this.events.request('processes:launch', 'ipfs'); }); } }