Merge pull request #1785 from interesse/saferun_args

Pass arguments from safeRun.sh to run.sh
This commit is contained in:
John McLear 2013-05-26 16:03:35 -07:00
commit 0aa0c69ba3
1 changed files with 10 additions and 8 deletions

View File

@ -16,6 +16,7 @@ TIME_BETWEEN_EMAILS=600 # 10 minutes
# DON'T EDIT AFTER THIS LINE
LAST_EMAIL_SEND=0
LOG="$1"
#Move to the folder where ep-lite is installed
cd `dirname $0`
@ -26,7 +27,7 @@ if [ -d "../bin" ]; then
fi
#check if a logfile parameter is set
if [ -z "$1" ]; then
if [ -z "${LOG}" ]; then
echo "Set a logfile as the first parameter"
exit 1
fi
@ -34,18 +35,19 @@ 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 )
if [ ! -f ${LOG} ]; then
touch ${LOG} || ( echo "Logfile '${LOG}' is not writeable" && exit 1 )
fi
#check if the file is writeable
if [ ! -w $1 ]; then
echo "Logfile '$1' is not writeable"
if [ ! -w ${LOG} ]; then
echo "Logfile '${LOG}' is not writeable"
exit 1
fi
#start the application
bin/run.sh >>$1 2>>$1
shift
bin/run.sh $@ >>${LOG} 2>>${LOG}
#Send email
if [ $ERROR_HANDLING = 1 ]; then
@ -53,13 +55,13 @@ do
TIME_SINCE_LAST_SEND=$(($TIME_NOW - $LAST_EMAIL_SEND))
if [ $TIME_SINCE_LAST_SEND -gt $TIME_BETWEEN_EMAILS ]; then
printf "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
printf "Server was restared at: $(date)\nThe last 50 lines of the log before the error happens:\n $(tail -n 50 ${LOG})" | mail -s "Pad Server was restarted" $EMAIL_ADDRESS
LAST_EMAIL_SEND=$TIME_NOW
fi
fi
echo "RESTART!" >>$1
echo "RESTART!" >>${LOG}
#Sleep 10 seconds before restart
sleep 10