I wrote a little server in node js, that I start as service when booting
My /etc/init.d/lightserver looks like this:
# Actions
case "$1" in
start)
# START
/usr/bin/lightserver
;;
stop)
# STOP
;;
restart)
# RESTART
;;
esac
exit 0
I want to be able to stop the server properly with the command "/etc/init.d/lightserver stop". Without using of kill or killall.
How to implement this function into my server?
var i = 0;
var connect = require('connect');
var sleep = require('sleep');
var exec = require('child_process').exec;
var j = 1;
var server = connect().
use(function(req, res) {
i++;
res.write('Hello World! ' + i);
res.end();
let code = 83028 + j;
j = 1 - j;
exec("./433Utils/RPi_utils/codesend " + code, function(error, stdout, stderr) {
console.log(stdout);
});
}).listen(64084);
console.log("Server has started and is listening to http://localhost:64084/");