Skip to content

Commit

Permalink
[refactor] Revert # 366, it's not that easy
Browse files Browse the repository at this point in the history
  • Loading branch information
alejandro committed Apr 8, 2012
1 parent 8adbac2 commit df680aa
Showing 1 changed file with 12 additions and 14 deletions.
26 changes: 12 additions & 14 deletions lib/app.js
Expand Up @@ -227,16 +227,15 @@ Controller.put = function (req, res, next) {
port : appdoc.port,
gitrepo : app_repo,
start : start,
running : String(appdoc.running) == 'true',
running : appdoc.running,
pid : appdoc.pid
});
});
} else {
var running = req.body.running;
switch (running) {
case "true":
case true:
if (appdoc.running || appdoc.running == "true") {
if (appdoc.running == "true") {
res.json({
status: "failure - application already running."
});
Expand All @@ -246,7 +245,7 @@ Controller.put = function (req, res, next) {
, running = "failed-to-start";
if (rv === true) {
success = "success";
running = true;
running = "true";
updateProxy(function (err) {
if (err) {
log.warn('Error updating Proxy! - ' + err);
Expand All @@ -259,7 +258,7 @@ Controller.put = function (req, res, next) {
port : appdoc.port,
gitrepo : app_repo,
start : appdoc.start,
running : String(running) == 'true',
running : running,
pid : pid
});
});
Expand All @@ -275,15 +274,15 @@ Controller.put = function (req, res, next) {

if (rv === true) {
success = "success";
running = true;
running = "true";
}
db.merge(appname, { running: running, pid: pid }, function (err, resp) {
res.json({
status : success,
port : appdoc.port,
gitrepo : app_repo,
start : appdoc.start,
running : String(running) == 'true',
running : running,
pid : pid
});
});
Expand All @@ -292,8 +291,7 @@ Controller.put = function (req, res, next) {
/*endcase running=restart */

case "false":
case false:
if (!appdoc.running) {
if (app.running != 'true') {
res.json({
status: "failure - application already stopped."
},408);
Expand All @@ -303,7 +301,7 @@ Controller.put = function (req, res, next) {
running = "failed-to-stop";
if (rv === true) {
success = "success";
running = false;
running = "false";
updateProxy(function (err) {
if (err) {
log.warn('Error updating Proxy! - ' + err);
Expand All @@ -316,7 +314,7 @@ Controller.put = function (req, res, next) {
port : appdoc.port,
gitrepo : app_repo,
start : appdoc.start,
running : String(running) == 'true',
running : running,
pid : 'unknown'
});
});
Expand Down Expand Up @@ -424,7 +422,7 @@ Controller.get = function (req, res, next) {
port : req.app.port,
gitrepo : gitRepo,
start : req.app.start,
running : String(req.app.running) == 'true',
running : req.app.running,
pid : req.app.pid
});

Expand Down Expand Up @@ -622,7 +620,7 @@ Controller.env_get = function (req, res, next) {
message : err.error + ' - ' + err.reason
},500);
} else {
var start = appdoc.start;
var start = req.body.start;
db.get(appname, function (err, doc) {
if (err) {
res.json({
Expand Down Expand Up @@ -929,7 +927,7 @@ var app_start = function (repo_id, callback) {
var pid = parseInt(pids, 10);
if (pid > 0) {
tapp.pid = pid;
tapp.running = true;
tapp.running = 'true';
}
apps.merge(doc.appname, tapp, function () {
callback(true, pid);
Expand Down

0 comments on commit df680aa

Please sign in to comment.