Changeset 689
- Timestamp:
- 01/08/2005 12:28:03 PM (4 years ago)
- Files:
-
- 1 modified
-
eddie/trunk/bin/eddie_wrapper (modified) (6 diffs)
Legend:
- Unmodified
- Added
- Removed
-
eddie/trunk/bin/eddie_wrapper
r668 r689 25 25 ######################################################################## 26 26 27 ## Address to receive restart messages. Set to empty or comment out to 28 ## disable sending messages. 29 #EDDIE_ADMIN=eddie-adm@domain.name 30 EDDIE_ADMIN=root 27 ## Address to receive restart messages, including tracebacks for any 28 ## bad exceptions. Set to empty or comment out to disable sending 29 ## messages. If set as an environment variable it will not be 30 ## over-written. Defaults to not set. 31 32 if [ $EDDIE_ADMIN = "" ] 33 then 34 #EDDIE_ADMIN=eddie-adm@domain.name 35 EDDIE_ADMIN= 36 fi 31 37 32 38 ## Failure to start EDDIE-Tool after MAX_RETRIES in a short period of time … … 47 53 ## Create (if necessary) /var/run/eddie/tmp 48 54 if [ ! -d /var/run/eddie/tmp ]; then 49 mkdir -p /var/run/eddie/tmp >/dev/null 2>&150 if [ $? -gt 0 ]; then51 echo '$0: "mkdir -p /var/run/eddie/tmp" failed.'52 RUNFILE=/var/tmp/eddie$$.out53 fi55 mkdir -p /var/run/eddie/tmp >/dev/null 2>&1 56 if [ $? -gt 0 ]; then 57 echo '$0: "mkdir -p /var/run/eddie/tmp" failed.' 58 RUNFILE=/var/tmp/eddie$$.out 59 fi 54 60 fi 55 61 56 62 ## Find mail program 57 63 if [ -x /bin/mailx ]; then # Solaris 58 MAIL=/bin/mailx64 MAIL=/bin/mailx 59 65 elif [ -x /bin/mail ]; then # Linux 60 MAIL=/bin/mail66 MAIL=/bin/mail 61 67 else 62 MAIL=mail # dunno...68 MAIL=mail # dunno... 63 69 fi 64 70 … … 70 76 if [ "$PGREP" = "" ] 71 77 then 72 PGREP="useps"78 PGREP="useps" 73 79 fi 74 80 … … 77 83 if [ "$EDDIEPATH" = "" ] 78 84 then 79 EDDIEPATH="."85 EDDIEPATH="." 80 86 fi 81 87 … … 86 92 87 93 while [ 1 ]; do 88 if [ "$PGREP" = "useps" ]89 then90 pid=`ps -ef | grep \.\*python\.\*eddie.py | grep -v grep | awk '{ print $2 }'`91 else92 pid=`$PGREP eddie.py`93 fi94 if [ "$PGREP" = "useps" ] 95 then 96 pid=`ps -ef | grep \.\*python\.\*eddie.py | grep -v grep | awk '{ print $2 }'` 97 else 98 pid=`$PGREP eddie.py` 99 fi 94 100 95 if [ "${pid}" != "" ]; then96 echo "Error: Eddie is already running."97 exit 298 fi101 if [ "${pid}" != "" ]; then 102 echo "Error: Eddie is already running." 103 exit 2 104 fi 99 105 100 #start_time=`$GDATE "+%s"`101 start_time=`$PYTHON -c "import time ; print int(time.time())"`106 #start_time=`$GDATE "+%s"` 107 start_time=`$PYTHON -c "import time ; print int(time.time())"` 102 108 103 $EDDIEPATH/eddie.py >>$RUNFILE109 $EDDIEPATH/eddie.py >>$RUNFILE 104 110 105 retcode=$? 111 retcode=$? 112 113 if [ $retcode -ne 0 ] 114 then 106 115 echo "eddie_wrapper: eddie died at `date` return code: $retcode" >> $RUNFILE 107 116 … … 109 118 restart_time=`expr $curtime - $start_time` 110 119 if [ $restart_time -lt 120 ]; then 111 tries=`expr $tries + 1`120 tries=`expr $tries + 1` 112 121 else 113 tries=0122 tries=0 114 123 fi 115 124 116 125 if [ $tries -gt $MAX_TRIES ]; then 117 echo "eddie_wrapper: Too many restarts ($tries) in a short time. eddie_wrapper quitting." >>$RUNFILE 118 119 if [ "$EDDIE_ADMIN" != "" ] 120 then 121 $MAIL -s "Eddie output on `hostname` at `date`" $EDDIE_ADMIN < $RUNFILE 122 fi 123 rm $RUNFILE 124 exit 3 126 echo "eddie_wrapper: Too many restarts ($tries) in a short time. eddie_wrapper quitting." >>$RUNFILE 125 127 fi 126 128 127 129 if [ "$EDDIE_ADMIN" != "" ] 128 130 then 129 $MAIL -s "Eddie output on `hostname` at `date`" $EDDIE_ADMIN < $RUNFILE 131 # Sent output to EDDIE_ADMIN if defined 132 $MAIL -s "Eddie output on `hostname` at `date`" $EDDIE_ADMIN < $RUNFILE 133 else 134 # Otherwise to stdout 135 cat $RUNFILE 130 136 fi 131 137 rm -f $RUNFILE 132 138 133 sleep 30 134 echo "eddie_wrapper: restarting Eddie at `date` [tries=$tries]." >> $RUNFILE 139 if [ $tries -gt $MAX_TRIES ]; then 140 exit 3 141 fi 142 143 sleep 60 144 else 145 sleep 5 146 fi 147 148 rm -f $RUNFILE 149 150 echo "eddie_wrapper: restarting Eddie at `date` [tries=$tries]." >> $RUNFILE 135 151 done 136 152
