-
-
Save ImTheDeveloper/14c3befa2ebf23ceac68 to your computer and use it in GitHub Desktop.
Node-Red Init.d Script - Updated
This file contains hidden or 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 initialisation | |
| ### END INIT INFO | |
| # Can be downloaded and installed in one go by using this command | |
| # sudo wget -O /tmp/download https://gist.github.com/bigmonkeyboy/9962293/download && sudo tar -zxf /tmp/download --strip-components 1 -C /etc/init.d && sudo update-rc.d node-red defaults | |
| 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 --max-old-space-size=128 red.js | |
| echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE | |
| # or | |
| #nohup node --max-old-space-size=128 red.js > /var/log/nodered.log & | |
| #echo $! > $PIDFILE | |
| ;; | |
| stop) | |
| echo "Stopping Node-Red.." | |
| sudo screen -S red -X quit | |
| # or | |
| #kill `cat $PIDFILE` | |
| rm -f $PIDFILE | |
| ;; | |
| restart) | |
| echo "Restarting Node-Red.." | |
| $0 stop | |
| $0 start | |
| ;; | |
| *) | |
| echo "Usage: $0 {start|stop|restart}" | |
| exit 1 | |
| esac | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment