diff --git a/lib/orchestrator.js b/lib/orchestrator.js index d6706b9..3ae9331 100644 --- a/lib/orchestrator.js +++ b/lib/orchestrator.js @@ -281,11 +281,15 @@ Orchestrator.prototype.read = function read(fn) { if (fn) fn = fn.bind(this); if (this.pidFile) { - fs.readFile(this.pidFile, 'utf-8', function reader(err, pid, cmd) { - this.pid = (pid || '').trim(); - - if (fn) fn(err, this.pid, cmd); - }.bind(this)); + if (fn) { + fs.readFile(this.pidFile, 'utf-8', function reader(err, pid, cmd) { + this.pid = (pid || '').trim(); + + fn(err, this.pid, cmd); + }.bind(this)); + } else { + this.pid = (fs.readFileSync(this.pidFile, 'utf-8') || '').trim(); + } return this; }