-
-
Save juzam/9002204 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
# Starts and stops node-red | |
# /etc/init.d/node_red | |
### BEGIN INIT INFO | |
# Provides: node_red | |
# Required-Start: $syslog | |
# Required-Stop: $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Node Red | |
### END INIT INFO | |
PIDFILE=/var/run/nodered.pid | |
#Load up node red when called | |
case "$1" in | |
start) | |
echo "Starting Node-Red.." | |
cd /home/pi/node-red | |
sudo screen -dmS red node red.js | |
echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE | |
;; | |
stop) | |
echo "Stopping Node-Red.." | |
sudo screen -S red -X quit | |
rm $PIDFILE | |
;; | |
restart) | |
echo "Restarting Node-Red.." | |
$0 stop | |
$0 start | |
;; | |
*) | |
echo "Usage: $0 {start|stop|restart}" | |
exit 1 | |
esac | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
check node-red with pidfile /var/run/nodered.pid | |
start program = "/etc/init.d/node_red start" | |
stop program = "/etc/init.d/node_red stop" | |
if failed port 1880 protocol HTTP request / with timeout 10 seconds then restart | |
if 3 restarts within 5 cycles then timeout |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment