Skip to content

Instantly share code, notes, and snippets.

@ImTheDeveloper
Forked from bigmonkeyboy/README.md
Created October 10, 2014 08:36
Show Gist options
  • Save ImTheDeveloper/14c3befa2ebf23ceac68 to your computer and use it in GitHub Desktop.
Save ImTheDeveloper/14c3befa2ebf23ceac68 to your computer and use it in GitHub Desktop.

Revisions

  1. ImTheDeveloper revised this gist Oct 10, 2014. 1 changed file with 1 addition and 3 deletions.
    4 changes: 1 addition & 3 deletions node-red
    Original file line number Diff line number Diff line change
    @@ -9,8 +9,6 @@
    # 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
    @@ -20,7 +18,7 @@ case "$1" in

    start)
    echo "Starting Node-Red.."
    su -l pi -c "cd node-red; screen -dmS red node --max-old-space-size=128$
    su -l pi -c "cd node-red; screen -dmS red node --max-old-space-size=64 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/node-red.log &
  2. @bigmonkeyboy bigmonkeyboy revised this gist Jul 25, 2014. 1 changed file with 3 additions and 3 deletions.
    6 changes: 3 additions & 3 deletions node-red
    Original file line number Diff line number Diff line change
    @@ -11,6 +11,7 @@
    ### 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

    @@ -19,8 +20,7 @@ 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
    su -l pi -c "cd node-red; screen -dmS red node --max-old-space-size=128$
    echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
    # or
    #nohup node --max-old-space-size=128 red.js > /var/log/node-red.log &
    @@ -29,7 +29,7 @@ start)
    stop)
    echo "Stopping Node-Red.."
    sudo screen -S red -X quit
    su -l pi -c "screen -S red -X quit"
    # or
    #kill `cat $PIDFILE`
    rm -f $PIDFILE
  3. @bigmonkeyboy bigmonkeyboy revised this gist Apr 8, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion node-red
    Original file line number Diff line number Diff line change
    @@ -23,7 +23,7 @@ start)
    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 &
    #nohup node --max-old-space-size=128 red.js > /var/log/node-red.log &
    #echo $! > $PIDFILE
    ;;

  4. @bigmonkeyboy bigmonkeyboy revised this gist Apr 8, 2014. 1 changed file with 6 additions and 6 deletions.
    12 changes: 6 additions & 6 deletions node-red
    Original file line number Diff line number Diff line change
    @@ -20,18 +20,18 @@ case "$1" in
    start)
    echo "Starting Node-Red.."
    cd /home/pi/node-red
    nohup node --max-old-space-size=128 red.js > /var/log/nodered.log &
    echo $! > $PIDFILE
    sudo screen -dmS red node --max-old-space-size=128 red.js
    echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
    # or
    #sudo screen -dmS red node --max-old-space-size=128 red.js
    #echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
    #nohup node --max-old-space-size=128 red.js > /var/log/nodered.log &
    #echo $! > $PIDFILE
    ;;

    stop)
    echo "Stopping Node-Red.."
    kill `cat $PIDFILE`
    sudo screen -S red -X quit
    # or
    #sudo screen -S red -X quit
    #kill `cat $PIDFILE`
    rm -f $PIDFILE
    ;;

  5. @bigmonkeyboy bigmonkeyboy revised this gist Apr 8, 2014. 1 changed file with 6 additions and 7 deletions.
    13 changes: 6 additions & 7 deletions node-red
    Original file line number Diff line number Diff line change
    @@ -20,19 +20,18 @@ 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
    nohup node --max-old-space-size=128 red.js > /var/log/nodered.log &
    echo $! > $PIDFILE
    # or
    #nohup node --max-old-space-size=128 red.js > /var/log/nodered.log &
    #echo $! > $PIDFILE
    #sudo screen -dmS red node --max-old-space-size=128 red.js
    #echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
    ;;

    stop)
    echo "Stopping Node-Red.."
    sudo screen -S red -X quit
    kill `cat $PIDFILE`
    # or
    #kill `cat $PIDFILE`

    #sudo screen -S red -X quit
    rm -f $PIDFILE
    ;;

  6. @bigmonkeyboy bigmonkeyboy revised this gist Apr 8, 2014. 1 changed file with 7 additions and 1 deletion.
    8 changes: 7 additions & 1 deletion node-red
    Original file line number Diff line number Diff line change
    @@ -22,12 +22,18 @@ start)
    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
    rm $PIDFILE
    # or
    #kill `cat $PIDFILE`

    rm -f $PIDFILE
    ;;

    restart)
  7. @bigmonkeyboy bigmonkeyboy revised this gist Apr 3, 2014. 1 changed file with 3 additions and 1 deletion.
    4 changes: 3 additions & 1 deletion node-red
    Original file line number Diff line number Diff line change
    @@ -1,5 +1,5 @@
    #! /bin/sh
    # Starts and stops node-red
    # Starts and stops Node-RED
    # /etc/init.d/node-red
    ### BEGIN INIT INFO
    # Provides: node-red
    @@ -9,6 +9,8 @@
    # 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

  8. @bigmonkeyboy bigmonkeyboy renamed this gist Apr 3, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Node-Red Init → node-red
    Original file line number Diff line number Diff line change
    @@ -2,12 +2,12 @@
    # Starts and stops node-red
    # /etc/init.d/node-red
    ### BEGIN INIT INFO
    # Provides: node_red
    # Provides: node-red
    # Required-Start: $syslog
    # Required-Stop: $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Node Red
    # Short-Description: Node-RED initialisation
    ### END INIT INFO

    PIDFILE=/var/run/nodered.pid
  9. @bigmonkeyboy bigmonkeyboy revised this gist Apr 3, 2014. 1 changed file with 0 additions and 6 deletions.
    6 changes: 0 additions & 6 deletions Node-Red Monit
    Original file line number Diff line number Diff line change
    @@ -1,6 +0,0 @@
    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
  10. @bigmonkeyboy bigmonkeyboy revised this gist Apr 3, 2014. 1 changed file with 1 addition and 1 deletion.
    2 changes: 1 addition & 1 deletion Node-Red Init
    Original file line number Diff line number Diff line change
    @@ -18,7 +18,7 @@ case "$1" in
    start)
    echo "Starting Node-Red.."
    cd /home/pi/node-red
    sudo screen -dmS red --max-old-space-size=128 node red.js
    sudo screen -dmS red node --max-old-space-size=128 red.js
    echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
    ;;

  11. @bigmonkeyboy bigmonkeyboy revised this gist Apr 3, 2014. 2 changed files with 4 additions and 4 deletions.
    4 changes: 2 additions & 2 deletions Node_Red Init → Node-Red Init
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    #! /bin/sh
    # Starts and stops node-red
    # /etc/init.d/node_red
    # /etc/init.d/node-red
    ### BEGIN INIT INFO
    # Provides: node_red
    # Required-Start: $syslog
    @@ -18,7 +18,7 @@ case "$1" in
    start)
    echo "Starting Node-Red.."
    cd /home/pi/node-red
    sudo screen -dmS red node red.js
    sudo screen -dmS red --max-old-space-size=128 node red.js
    echo `screen -ls red | sed -n '2p' | cut -f1 -d.` > $PIDFILE
    ;;

    4 changes: 2 additions & 2 deletions Node_Red Monit → Node-Red Monit
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    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"
    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
  12. @juzam juzam revised this gist Feb 14, 2014. 1 changed file with 2 additions and 2 deletions.
    4 changes: 2 additions & 2 deletions Node_Red Monit
    Original file line number Diff line number Diff line change
    @@ -1,6 +1,6 @@
    check node-red with pidfile /var/run/nodered.pid
    start program = "/etc/init.d/nodered start"
    stop program = "/etc/init.d/nodered stop"
    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
  13. @juzam juzam revised this gist Feb 14, 2014. 1 changed file with 6 additions and 0 deletions.
    6 changes: 6 additions & 0 deletions Node_Red Monit
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,6 @@
    check node-red with pidfile /var/run/nodered.pid
    start program = "/etc/init.d/nodered start"
    stop program = "/etc/init.d/nodered stop"

    if failed port 1880 protocol HTTP request / with timeout 10 seconds then restart
    if 3 restarts within 5 cycles then timeout
  14. @juzam juzam revised this gist Feb 14, 2014. 1 changed file with 4 additions and 0 deletions.
    4 changes: 4 additions & 0 deletions Node_Red Init
    Original file line number Diff line number Diff line change
    @@ -10,18 +10,22 @@
    # 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)
  15. ImTheDeveloper revised this gist Jan 26, 2014. 1 changed file with 2 additions and 3 deletions.
    5 changes: 2 additions & 3 deletions Node_Red Init
    Original file line number Diff line number Diff line change
    @@ -1,9 +1,8 @@

    #! /bin/sh
    # Starts and stops node-red
    # /etc/init.d/node_red1
    # /etc/init.d/node_red
    ### BEGIN INIT INFO
    # Provides: node_red1
    # Provides: node_red
    # Required-Start: $syslog
    # Required-Stop: $syslog
    # Default-Start: 2 3 4 5
  16. ImTheDeveloper created this gist Jan 26, 2014.
    37 changes: 37 additions & 0 deletions Node_Red Init
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,37 @@

    #! /bin/sh
    # Starts and stops node-red
    # /etc/init.d/node_red1
    ### BEGIN INIT INFO
    # Provides: node_red1
    # Required-Start: $syslog
    # Required-Stop: $syslog
    # Default-Start: 2 3 4 5
    # Default-Stop: 0 1 6
    # Short-Description: Node Red
    ### END INIT INFO

    #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
    ;;

    stop)
    echo "Stopping Node-Red.."
    sudo screen -S red -X quit
    ;;

    restart)
    echo "Restarting Node-Red.."
    $0 stop
    $0 start
    ;;
    *)
    echo "Usage: $0 {start|stop|restart}"
    exit 1
    esac