Skip to content

Instantly share code, notes, and snippets.

@taka-wang
Last active March 14, 2016 03:19
Show Gist options
  • Save taka-wang/5a3c1496f0e09623bde5 to your computer and use it in GitHub Desktop.
Save taka-wang/5a3c1496f0e09623bde5 to your computer and use it in GitHub Desktop.
node-red init script
#!/bin/sh
#
case "$1" in
start )
echo -n "Starting Node Services: "
sleep 5
cd /usr/bin/
./core > /tmp/core.log 2>&1 &
sleep 2
cd /root/node-red
node red.js > /tmp/node-red.log 2>&1 &
if [ "$?" = "0" ]; then
echo " [ OK ]"
else
echo " [ Fail ]"
fi
;;
stop )
echo -n "Stopping Node Services: "
kill -9 `pidof core` > /dev/null 2>&1
sleep 2
kill -9 `pidof node` > /dev/null 2>&1
sleep 2
tr=`ps aux | grep 'node' | grep -v grep`
if [ "x$tr" = "x" ]; then
echo " [ OK ]"
else
echo " [ Fail ]"
fi
;;
restart )
$0 stop
sleep 2
$0 start
if [ "$?" != "0" ]; then
exit 1
fi
;;
*)
echo "Usage: /etc/init.d/nodered {start|stop|restart}"
exit 1
esac
exit 0
wget http://172.16.9.171/node-red.zip
wget http://172.16.9.171/core
wget http://172.16.9.171/nodered
1. Unzip node-red to /root
2. Copy core to /usr/bin
3. Copy init scripts to /etc/init.d/
cd /etc/init.d/
ln -s etc/init.d/nodered /etc/rc3.d/S971nodered
chmod +x S971nodered
chmod +x /usr/bin/core
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment