Skip to content

Commit

Permalink
feat: add logging for debug (#195)
Browse files Browse the repository at this point in the history
  • Loading branch information
richardschneider authored and daviddias committed Feb 6, 2018
1 parent 4e8b8db commit 86b0ab0
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 0 deletions.
2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@
"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",
Expand All @@ -79,6 +80,7 @@
"readable-stream": "^2.3.3",
"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",
Expand Down
4 changes: 4 additions & 0 deletions src/daemon-node.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,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
Expand Down Expand Up @@ -262,13 +263,15 @@ 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)

const disposable = this.disposable
const clean = this.cleanup.bind(this)
subprocess.once('close', () => {
debug('killed', subprocess.pid)
clearTimeout(timeout)
this.subprocess = null
this._started = false
Expand All @@ -278,6 +281,7 @@ class Node {
callback()
})

debug('killing', subprocess.pid)
subprocess.kill('SIGTERM')
this.subprocess = null
}
Expand Down
3 changes: 3 additions & 0 deletions src/exec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 || {}
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit 86b0ab0

Please sign in to comment.