Added functions to check loggers and restart loggers

This commit is contained in:
Patrick McDonagh
2016-02-03 10:26:40 -06:00
parent 0d1bc7b088
commit 851a90283f
2 changed files with 28 additions and 3 deletions

View File

@@ -21,14 +21,14 @@ case "$1" in
# run application you want to start
#python /home/poconsole/src/dataLogger/alarmLogger.py &
#python /home/poconsole/src/dataLogger/dataLogger.py &
/usr/bin/python /home/poconsole/tagserver/python/tagserver_SQLite.py > /dev/null 2>&1 & echo $! > "/root/solar_ww.pid"
/usr/bin/python /home/poconsole/tagserver/python/tagserver_SQLite.py > /dev/null 2>&1 & echo $! > "/root/tagserver.pid"
;;
stop)
echo "Stopping loggers"
# kill application you want to stop
#killall python
kill -9 $(cat /root/solar_ww.pid)
kill -9 $(cat /root/tagserver.pid)
;;
*)
@@ -37,4 +37,4 @@ case "$1" in
;;
esac
exit 0
exit 0

View File

@@ -277,3 +277,28 @@ exports.latestValueAllTags = function(req, res){
});
});
};
exports.checkLoggerStatus = function(req, res){
var fs = require('fs');
// var ps = require("ps-node");
var running = require("is-running");
fs.readFile('/root/dataLogger.pid', function (derr,ddata) {
if (derr) {
console.log("Problem getting PID of tagserver");
res.json({status:"error", message: "Problem getting PID of tagserver"});
} else {
res.json({status: "OK", running: running(ddata)});
}
});
};
exports.restartLogger = function(req, res){
var exec = require('child_process').exec;
exec('/etc/init.d/loggers start', function(error, stdout, stderr){
if (error){
res.json({status:"error", message:error});
} else {
res.json({status:"OK"});
}
});
};