Fixed simple-restarter script

This commit is contained in:
Yehonal
2018-07-17 14:55:52 +00:00
parent 8e9faf8488
commit 3fb937f003
2 changed files with 23 additions and 7 deletions
+5 -2
View File
@@ -189,8 +189,11 @@ function inst_module_remove {
function inst_simple_restarter { function inst_simple_restarter {
echo "Running $1 in background..." echo "Running $1 ..."
bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1" & bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1"
echo
#disown -a
#jobs -l
} }
function inst_download_client_data { function inst_download_client_data {
+16 -3
View File
@@ -9,6 +9,8 @@ _bin_file=$2
_instant_crash_cnt=0 _instant_crash_cnt=0
_total_crashes=0 _total_crashes=0
trap 'echo "va bene"' SIGHUP
while true while true
do do
if [ ! -f "$_bin_path/$_bin_file" ]; then if [ ! -f "$_bin_path/$_bin_file" ]; then
@@ -18,13 +20,24 @@ do
STARTING_TIME=$(date +%s) STARTING_TIME=$(date +%s)
cd "$_bin_path" && "./$_bin_file" &>/dev/null; echo "$_bin_file crashed (?), restarting..." cd "$_bin_path" && "./$_bin_file" # &>/dev/null;
_exit_code=$?
echo "exit code: $_exit_code"
# stop restarter on SIGKILL (disabled for now)
# 128 + 9 (SIGKILL)
#if [ $_exit_code -eq 137 ]; then
# echo "$_bin_file has been killed"
# exit 0
#fi
echo "$_bin_file crashed (?), restarting..."
ENDING_TIME=$(date +%s) ENDING_TIME=$(date +%s)
DIFFERENCE=$(( $ENDING_TIME - $STARTING_TIME )) DIFFERENCE=$(( $ENDING_TIME - $STARTING_TIME ))
echo "Crashed after $DIFFERENCE seconds, total crashes: $_total_crashes"
((_total_crashes++)) ((_total_crashes++))
echo "$_bin_file Crashed after $DIFFERENCE seconds, total crashes: $_total_crashes"
if [ $DIFFERENCE -lt 10 ]; then if [ $DIFFERENCE -lt 10 ]; then
# increment instant crash if runtime is lower than 10 seconds # increment instant crash if runtime is lower than 10 seconds
@@ -34,7 +47,7 @@ do
fi fi
if [ $_instant_crash_cnt -gt 5 ]; then if [ $_instant_crash_cnt -gt 5 ]; then
echo "Restarted exited. Infinite crash loop prevented. Please check your system" echo "$_bin_file Restarter exited. Infinite crash loop prevented. Please check your system"
exit 0 exit 0
fi fi
done done