From c33f56e3cf2dea2d6c03a1ce028f09a4e2e015dc Mon Sep 17 00:00:00 2001 From: Tjatse Date: Mon, 26 Jan 2015 18:46:59 +0800 Subject: [PATCH] fix critical bugs @v0.14.0 --- lib/forever.js | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/lib/forever.js b/lib/forever.js index b0af69b7..8309fdef 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -223,17 +223,18 @@ function stopOrRestart(action, event, format, target) { }); } - var procs = processes; + var procs; if (target !== undefined && target !== null) { if (isNaN(target)) { procs = forever.findByScript(target, processes); } - procs = procs || forever.findById(target, processes) || forever.findByIndex(target, processes) || forever.findByUid(target, processes) || forever.findByPid(target, processes); + }else{ + procs = processes; } if (procs && procs.length > 0) { @@ -739,11 +740,14 @@ forever.findByScript = function (script, processes) { // Finds the process with the specified uid. // forever.findByUid = function (script, processes) { - return !processes + var procs = !processes ? null : processes.filter(function (p) { return p.uid === script; }); + + if (procs && procs.length === 0) { procs = null; } + return procs; }; // @@ -753,11 +757,14 @@ forever.findByUid = function (script, processes) { // Finds the process with the specified pid. // forever.findByPid = function (pid, processes) { - return !processes + var procs = !processes ? null : processes.filter(function (p) { return p.pid == pid; }); + + if (procs && procs.length === 0) { procs = null; } + return procs; }; //