From 51dc2c7ac87eda6c39fd3ff8f0378128991739a1 Mon Sep 17 00:00:00 2001 From: Anas Date: Sun, 30 Jun 2019 00:01:26 +0530 Subject: [PATCH] use readFileSync for reading pid file --- lib/orchestrator.js | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) 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; }