diff --git a/apps/installer/includes/functions.sh b/apps/installer/includes/functions.sh index 31284aa19..9102ca43a 100644 --- a/apps/installer/includes/functions.sh +++ b/apps/installer/includes/functions.sh @@ -189,8 +189,11 @@ function inst_module_remove { function inst_simple_restarter { - echo "Running $1 in background..." - bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1" & + echo "Running $1 ..." + bash "$AC_PATH_APPS/startup-scripts/simple-restarter" "$AC_BINPATH_FULL" "$1" + echo + #disown -a + #jobs -l } function inst_download_client_data { @@ -199,4 +202,4 @@ function inst_download_client_data { echo "Downloading client data in: $path/data.zip ..." curl -L https://github.com/wowgaming/client-data/releases/download/v4/data.zip > "$path/data.zip" \ && unzip -o "$path/data.zip" -d "$path/" && rm "$path/data.zip" -} \ No newline at end of file +} diff --git a/apps/startup-scripts/simple-restarter b/apps/startup-scripts/simple-restarter old mode 100644 new mode 100755 index 47985fc12..33d4e3f23 --- a/apps/startup-scripts/simple-restarter +++ b/apps/startup-scripts/simple-restarter @@ -9,6 +9,8 @@ _bin_file=$2 _instant_crash_cnt=0 _total_crashes=0 +trap 'echo "va bene"' SIGHUP + while true do if [ ! -f "$_bin_path/$_bin_file" ]; then @@ -18,13 +20,24 @@ do 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) DIFFERENCE=$(( $ENDING_TIME - $STARTING_TIME )) - echo "Crashed after $DIFFERENCE seconds, total crashes: $_total_crashes" ((_total_crashes++)) + echo "$_bin_file Crashed after $DIFFERENCE seconds, total crashes: $_total_crashes" if [ $DIFFERENCE -lt 10 ]; then # increment instant crash if runtime is lower than 10 seconds @@ -34,7 +47,7 @@ do fi 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 fi -done \ No newline at end of file +done