From 9c787dfbbd16b80443d03ac434a73c79be3dc0ed Mon Sep 17 00:00:00 2001 From: Andrew Radev Date: Fri, 13 Apr 2012 13:03:04 +0300 Subject: [PATCH] Stop or restart a process by its uid --- lib/forever.js | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/lib/forever.js b/lib/forever.js index cb5d6401..09047482 100644 --- a/lib/forever.js +++ b/lib/forever.js @@ -180,7 +180,8 @@ function stopOrRestart(action, event, format, target) { if (target) { procs = forever.findByIndex(target, processes) - || forever.findByScript(target, processes); + || forever.findByScript(target, processes) + || forever.findByUid(target, processes); } if (procs && procs.length > 0) { @@ -555,6 +556,20 @@ forever.findByScript = function (script, processes) { }); }; +// +// ### function findByUid (uid, processes) +// #### @uid {string} The uid of the process to find. +// #### @processes {Array} Set of processes to find in. +// Finds the process with the specified uid. +// +forever.findByScript = function (script, processes) { + return !processes + ? null + : processes.filter(function (p) { + return p.uid === script; + }); +}; + // // ### function format (format, procs) // #### @format {Boolean} Value indicating if processes should be formatted