From 617e0303ec91b17a7c7385089230487944981918 Mon Sep 17 00:00:00 2001 From: Richard Schneider Date: Mon, 29 Jan 2018 15:24:10 +1300 Subject: [PATCH] feat: debug logging --- package.json | 3 ++- src/daemon-node.js | 4 ++++ src/exec.js | 3 +++ 3 files changed, 9 insertions(+), 1 deletion(-) diff --git a/package.json b/package.json index 65db903a..83f05a6e 100644 --- a/package.json +++ b/package.json @@ -67,9 +67,11 @@ "dependencies": { "async": "^2.6.0", "boom": "^7.1.1", + "debug": "^3.1.0", "detect-node": "^2.0.3", "hapi": "^16.6.2", "hat": "0.0.3", + "ipfs-api": "^17.3.0", "ipfs-repo": "^0.18.5", "joi": "^13.0.2", "lodash.clone": "^4.5.0", @@ -80,7 +82,6 @@ "rimraf": "^2.6.2", "safe-json-parse": "^4.0.0", "shutdown": "^0.3.0", - "ipfs-api": "^17.3.0", "stream-http": "^2.7.2", "subcomandante": "^1.0.5", "superagent": "^3.8.2", diff --git a/src/daemon-node.js b/src/daemon-node.js index 7909cd1f..4021d7cd 100644 --- a/src/daemon-node.js +++ b/src/daemon-node.js @@ -11,6 +11,7 @@ const once = require('once') const truthy = require('truthy') const utils = require('./utils') const flatten = require('./utils').flatten +const debug = require('debug')('ipfsd-ctl:deamon-node') const tryJsonParse = utils.tryJsonParse const parseConfig = utils.parseConfig @@ -262,17 +263,20 @@ class Node { // need a local var for the closure, as we clear the var. const subprocess = this.subprocess const timeout = setTimeout(() => { + debug('kill timeout, using SIGKILL', subprocess.pid) subprocess.kill('SIGKILL') callback() }, GRACE_PERIOD) subprocess.once('close', () => { + debug('killed', subprocess.pid) clearTimeout(timeout) this.subprocess = null this._started = false callback() }) + debug('killing', subprocess.pid) subprocess.kill('SIGTERM') this.subprocess = null } diff --git a/src/exec.js b/src/exec.js index 3830c3f0..a846daa8 100644 --- a/src/exec.js +++ b/src/exec.js @@ -2,6 +2,8 @@ const run = require('subcomandante') const once = require('once') +const debug = require('debug')('ipfsd-ctl:exec') +const path = require('path') function exec (cmd, args, opts, handlers) { opts = opts || {} @@ -47,6 +49,7 @@ function exec (cmd, args, opts, handlers) { }) } + debug(path.basename(cmd), args.join(' ')) const command = run(cmd, args, opts) if (listeners.data) {