Added crash restart support for non Upstart Init services
Bryan Roe committed
Jul 22, 2019 at 17:58 UTC
b5bc6934a56db422d3c7a37ed355f3c48e7bfa0f
1 file changed
+2
-1
agents/meshinstall-initd.sh
+2
-1
@@ -20,7 +20,8 @@ start() {
20
return 1
21
fi
22
echo 'Starting service…' >&2
23
- local CMD="$SCRIPT &> \"$LOGFILE\" & echo \$!"
23
+ local CMD="$SCRIPT -exec \"var child; process.on('SIGTERM', function () { child.removeAllListeners('exit'); child.kill(); process.exit(); }); function start() { child = require('child_process').execFile(process.execPath, [process.argv0, \"\"]); child.stdout.on('data', function (c) { }); child.stderr.on('data', function (c) { }); child.on('exit', function (status) { start(); }); } start();\" &> \"$LOGFILE\" & echo \$!"
24
+
25
cd /usr/local/mesh
26
su -c "$CMD" $RUNAS > "$PIDFILE"
27
echo 'Service started' >&2