Skip to content

Instantly share code, notes, and snippets.

@hovissimo
Forked from bigmonkeyboy/README.md
Last active August 29, 2015 14:04
Show Gist options
  • Save hovissimo/94717627e8b4c960b033 to your computer and use it in GitHub Desktop.
Save hovissimo/94717627e8b4c960b033 to your computer and use it in GitHub Desktop.
#! /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
# Note: this runs as the user called pi
PIDFILE=/var/run/nodered.pid
#Load up node red when called
case "$1" in
start)
echo "Starting Node-Red.."
su -l pi -c "cd node-red; screen -dmS red node --max-old-space-size=256$
echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
# or
#nohup node --max-old-space-size=256 red.js > /var/log/node-red.log &
#echo $! > $PIDFILE
;;
stop)
echo "Stopping Node-Red.."
su -l pi -c "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
@ImTheDeveloper
Copy link

yeap there is some truncation there. Likely the original creator took this from a nano session and some of the text was missed off. You need to add in --max-old-space-size=256 red.js

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment