From 2e163f2924efd020e77d2d11569d21b3b134b1dc Mon Sep 17 00:00:00 2001 From: Peter 'Pita' Martischka Date: Tue, 26 Jul 2011 17:00:56 +0100 Subject: reorganzied the bin folder --- bin/debugRun.sh | 19 ++++++++++++++++ bin/runDebug.sh | 19 ---------------- bin/runSafe.sh | 67 --------------------------------------------------------- bin/runTests.sh | 14 ------------ bin/safeRun.sh | 67 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 86 insertions(+), 100 deletions(-) create mode 100755 bin/debugRun.sh delete mode 100755 bin/runDebug.sh delete mode 100755 bin/runSafe.sh delete mode 100755 bin/runTests.sh create mode 100755 bin/safeRun.sh (limited to 'bin') diff --git a/bin/debugRun.sh b/bin/debugRun.sh new file mode 100755 index 00000000..8e1d737e --- /dev/null +++ b/bin/debugRun.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +type -P node-inspector &>/dev/null || { + echo "You need to install node-inspector to run the tests!" >&2 + echo "You can install it with npm" >&2 + echo "Run: npm install -g node-inspector" >&2 + exit 1 +} + +node-inspector & + +echo "If you new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8" + +if [ -d "../bin" ]; then + cd "../" +fi + +cd "node" +node --debug server.js diff --git a/bin/runDebug.sh b/bin/runDebug.sh deleted file mode 100755 index 46eec8e8..00000000 --- a/bin/runDebug.sh +++ /dev/null @@ -1,19 +0,0 @@ -#!/bin/bash - -type -P node-inspector &>/dev/null || { - echo "You need to install node-inspector to run the tests!" >&2 - echo "You can install it with npm" >&2 - echo "Run: npm install node-inspector" >&2 - exit 1 -} - -node-inspector & - -echo "If you new to node-inspector, take a look at this video: http://youtu.be/AOnK3NVnxL8" - -if [ -d "../bin" ]; then - cd "../" -fi - -cd "node" -node --debug server.js diff --git a/bin/runSafe.sh b/bin/runSafe.sh deleted file mode 100755 index 180de1fe..00000000 --- a/bin/runSafe.sh +++ /dev/null @@ -1,67 +0,0 @@ -#!/bin/bash - -#This script ensures that ep-lite is automatically restarting after an error happens - -#Handling Errors -# 0 silent -# 1 email -ERROR_HANDLING=0 -# Your email address which should recieve the error messages -EMAIL_ADDRESS="no-reply@example.com" -# Sets the minimun amount of time betweens the sending of error emails. -# This ensures you not get spamed while a endless reboot loop -# It's the time in seconds -TIME_BETWEEN_EMAILS=600 # 10 minutes - -# DON'T EDIT AFTER THIS LINE - -LAST_EMAIL_SEND=0 - -#Move to the folder where ep-lite is installed -FOLDER=$(dirname $(readlink -f $0)) -cd $FOLDER - -#Was this script started in the bin folder? if yes move out -if [ -d "../bin" ]; then - cd "../" -fi - -#check if a logfile parameter is set -if [ -z "$1" ]; then - echo "Set a logfile as the first parameter" - exit 1 -fi - -while [ 1 ] -do - #try to touch the file if it doesn't exist - if [ ! -f $1 ]; then - touch $1 || ( echo "Logfile '$1' is not writeable" && exit 1 ) - fi - - #check if the file is writeable - if [ ! -w $1 ]; then - echo "Logfile '$1' is not writeable" - exit 1 - fi - - #start the application - bin/run.sh >>$1 2>>$1 - - #Send email - if [ $ERROR_HANDLING == 1 ]; then - TIME_NOW=$(date +%s) - TIME_SINCE_LAST_SEND=$(($TIME_NOW - $LAST_EMAIL_SEND)) - - if [ $TIME_SINCE_LAST_SEND -gt $TIME_BETWEEN_EMAILS ]; then - echo -e "Server was restared at: $(date)\nThe last 50 lines of the log before the error happens:\n $(tail -n 50 $1)" | mail -s "Pad Server was restarted" $EMAIL_ADDRESS - - LAST_EMAIL_SEND=$TIME_NOW - fi - fi - - echo "RESTART!" >>$1 - - #Sleep 10 seconds before restart - sleep 10 -done diff --git a/bin/runTests.sh b/bin/runTests.sh deleted file mode 100755 index f22004e3..00000000 --- a/bin/runTests.sh +++ /dev/null @@ -1,14 +0,0 @@ -#!/bin/bash - -type -P nodeunit &>/dev/null || { - echo "You need to install Nodeunit to run the tests!" >&2 - echo "You can install it with npm" >&2 - echo "Run: npm install nodeunit" >&2 - exit 1 -} - -if [ -d "../bin" ]; then - cd "../" -fi - -nodeunit tests diff --git a/bin/safeRun.sh b/bin/safeRun.sh new file mode 100755 index 00000000..180de1fe --- /dev/null +++ b/bin/safeRun.sh @@ -0,0 +1,67 @@ +#!/bin/bash + +#This script ensures that ep-lite is automatically restarting after an error happens + +#Handling Errors +# 0 silent +# 1 email +ERROR_HANDLING=0 +# Your email address which should recieve the error messages +EMAIL_ADDRESS="no-reply@example.com" +# Sets the minimun amount of time betweens the sending of error emails. +# This ensures you not get spamed while a endless reboot loop +# It's the time in seconds +TIME_BETWEEN_EMAILS=600 # 10 minutes + +# DON'T EDIT AFTER THIS LINE + +LAST_EMAIL_SEND=0 + +#Move to the folder where ep-lite is installed +FOLDER=$(dirname $(readlink -f $0)) +cd $FOLDER + +#Was this script started in the bin folder? if yes move out +if [ -d "../bin" ]; then + cd "../" +fi + +#check if a logfile parameter is set +if [ -z "$1" ]; then + echo "Set a logfile as the first parameter" + exit 1 +fi + +while [ 1 ] +do + #try to touch the file if it doesn't exist + if [ ! -f $1 ]; then + touch $1 || ( echo "Logfile '$1' is not writeable" && exit 1 ) + fi + + #check if the file is writeable + if [ ! -w $1 ]; then + echo "Logfile '$1' is not writeable" + exit 1 + fi + + #start the application + bin/run.sh >>$1 2>>$1 + + #Send email + if [ $ERROR_HANDLING == 1 ]; then + TIME_NOW=$(date +%s) + TIME_SINCE_LAST_SEND=$(($TIME_NOW - $LAST_EMAIL_SEND)) + + if [ $TIME_SINCE_LAST_SEND -gt $TIME_BETWEEN_EMAILS ]; then + echo -e "Server was restared at: $(date)\nThe last 50 lines of the log before the error happens:\n $(tail -n 50 $1)" | mail -s "Pad Server was restarted" $EMAIL_ADDRESS + + LAST_EMAIL_SEND=$TIME_NOW + fi + fi + + echo "RESTART!" >>$1 + + #Sleep 10 seconds before restart + sleep 10 +done -- cgit v1.2.3