Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

[master] Restart app by name script

  • Loading branch information...
commit 97903db81810e05ca0222b1f4a779b82a75c65ad 1 parent 5aa2e7c
@alejandro alejandro authored
Showing with 30 additions and 3 deletions.
  1. +23 −3 lib/app.js
  2. +7 −0 lib/restart_app.sh
View
26 lib/app.js
@@ -965,7 +965,7 @@ var app_start = function (repo_id, callback) {
};
var app_restart = function (repo_id, callback) {
- app_stop(repo_id, function (rv) {
+ app_stop(repo_id, function (rev) {
setTimeout(function () {
app_start(repo_id, function (rv, pid) {
if (rv === false) {
@@ -977,6 +977,26 @@ var app_restart = function (repo_id, callback) {
}, 1500);
}, true);
};
-
// expose restart method, withouth authentication but private (not via REST since we don't have apps)
-module.exports.apprestart = app_restart;
+module.exports.apprestart = app_restart;
+
+var restart_by_name = function(appname,cb){
+ var db =lib.get_couchdb_database('apps');
+ db.get(appname, function(e,doc){
+ if (!e && doc && doc.repo_id){
+ console.log('Restarting => \t',doc.name);
+ app_restart(doc.repo_id, function(running, pid){
+ if (running){
+ console.log('Restarted')
+ } else {
+ console.log('Failed to restart')
+ }
+ cb(running,id);
+ })
+ }else {
+ cb('DEAD')
+ }
+ });
+};
+
+module.exports.restart_by_name = restart_by_name;
View
7 lib/restart_app.sh
@@ -0,0 +1,7 @@
+#!/bin/bash
+
+sudo su nodester
+export OLDAPP=$APP
+export APP=$0;
+echo "require('./app').restart_by_name(${APP},function(){console.log(arguments);})" | node
+export APP=$OLDAPP
Please sign in to comment.
Something went wrong with that request. Please try again.