Răsfoiți Sursa

monitor will now restart the server if requested earlier

Daniel Gibbs 2 ani în urmă
părinte
comite
c357d2edd6
2 a modificat fișierele cu 17 adăugiri și 0 ștergeri
  1. 13 0
      lgsm/modules/command_monitor.sh
  2. 4 0
      lgsm/modules/command_stop.sh

+ 13 - 0
lgsm/modules/command_monitor.sh

@@ -109,6 +109,18 @@ fn_monitor_check_stopping() {
 	fi
 }
 
+fn_monitor_check_restart_request() {
+	if [ -f "${lockdir}/${selfname}-restart-request.lock" ]; then
+		fn_print_dots "Checking restart: "
+		fn_print_checking_eol
+		fn_print_info "Checking restart: Restart requested: "
+		fn_print_info_eol_nl
+		fn_script_log_info "Checking restart: Restart requested"
+		command_restart.sh
+		core_exit.sh
+	fi
+}
+
 fn_monitor_check_backup() {
 	# Remove stale lockfile.
 	if [ -f "${lockdir}/backup.lock" ]; then
@@ -416,4 +428,5 @@ if [ "${querymode}" != "1" ]; then
 
 	fn_monitor_loop
 fi
+fn_monitor_check_restart_request
 core_exit.sh

+ 4 - 0
lgsm/modules/command_stop.sh

@@ -20,8 +20,12 @@ fn_stop_players_online() {
 					if [ -n "${gdplayers}" ] && [ "${gdplayers}" -ne 0 ]; then
 						fn_print_info "Server will not stop while ${gdplayers} players are on the server"
 						fn_script_log_info "Server will not stop while ${gdplayers} players are on the server"
+						date '+%s' > "${lockdir:?}/${selfname}-restart-request.lock"
 						core_exit.sh
 					else
+						if [ -f "${lockdir:?}/${selfname}-restart-request.lock" ]; then
+							rm -f "${lockdir:?}/${selfname}-restart-request.lock"
+						fi
 						break
 					fi
 				fi