Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Refactoring server-side

  • Loading branch information...
commit d19ab269b40331e26a265221f35a789283755cca 1 parent b1252ad
@FGRibreau authored
Showing with 42 additions and 15 deletions.
  1. +22 −8 app.coffee
  2. +20 −7 app.js
View
30 app.coffee
@@ -9,19 +9,30 @@ class foreverUI
constructor: ->
- # Get process logs
- info: (uid, cb) ->
+
+ findProcessByUID: (uid, cb) ->
+ forever.list("", (err, processes) ->
+ if(err)
+ return cb(null)
+
+ cb(_.find(processes, (o) -> o.uid == uid))
+ )
+
+ findIndexByUID: (uid, cb) ->
forever.list("", (err, processes) ->
if(err)
return cb(null)
- proc = _.find(processes, (o) ->
- o.uid == uid
- )
+ cb(_.find(processes, (o) -> o.uid == uid))
+ )
+
+
+ # Get process logs
+ info: (uid, cb) ->
- console.log proc
+ @findProcessByUID(uid, (proc) ->
async.map([proc.logFile, proc.outFile, proc.errFile].filter((s) -> s != undefined), (filename, cb) ->
@@ -38,11 +49,14 @@ class foreverUI
cb results
)
)
+ stop: (uid, cb) ->
- stop: (cb) ->
+ @findProcessByUID(uid, (proc) ->
+
+ )
cb {}
- restart: (cb) ->
+ restart: (uid, cb) ->
cb {}
UI = new foreverUI()
View
27 app.js
@@ -7,16 +7,28 @@
_ = require('underscore');
foreverUI = (function() {
function foreverUI() {}
- foreverUI.prototype.info = function(uid, cb) {
+ foreverUI.prototype.findProcessByUID = function(uid, cb) {
return forever.list("", function(err, processes) {
- var proc;
if (err) {
return cb(null);
}
- proc = _.find(processes, function(o) {
+ return cb(_.find(processes, function(o) {
return o.uid === uid;
- });
- console.log(proc);
+ }));
+ });
+ };
+ foreverUI.prototype.findIndexByUID = function(uid, cb) {
+ return forever.list("", function(err, processes) {
+ if (err) {
+ return cb(null);
+ }
+ return cb(_.find(processes, function(o) {
+ return o.uid === uid;
+ }));
+ });
+ };
+ foreverUI.prototype.info = function(uid, cb) {
+ return this.findProcessByUID(uid, function(proc) {
return async.map([proc.logFile, proc.outFile, proc.errFile].filter(function(s) {
return s !== void 0;
}), function(filename, cb) {
@@ -34,10 +46,11 @@
});
});
};
- foreverUI.prototype.stop = function(cb) {
+ foreverUI.prototype.stop = function(uid, cb) {
+ this.findProcessByUID(uid, function(proc) {});
return cb({});
};
- foreverUI.prototype.restart = function(cb) {
+ foreverUI.prototype.restart = function(uid, cb) {
return cb({});
};
return foreverUI;
Please sign in to comment.
Something went wrong with that request. Please try again.