From 714884d291dc81eb11a2eb9a790dfd53c73cb5ee Mon Sep 17 00:00:00 2001 From: Price Hiller Date: Sat, 1 Jan 2022 02:25:33 -0600 Subject: [PATCH] Notify when session attempt kill too high --- Scripts/7D2D-Manage.bash | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/Scripts/7D2D-Manage.bash b/Scripts/7D2D-Manage.bash index 56d76bb..301ef25 100644 --- a/Scripts/7D2D-Manage.bash +++ b/Scripts/7D2D-Manage.bash @@ -376,11 +376,20 @@ kill_server() { return 1 fi else + local attempts + local max_attempts + attempts=0 + max_attempts=3 while tmux has-session -t "${session}" > /dev/null 2>&1; do + if [[ "${attempts}" -eq "${max_attempts}" ]]; then + log "error" "Unable to kill session ${session}" + return 1 + fi log "info" "Attempting to gracefully kill $(important "${session}")" - tmux send-keys -t "7D2D-Server-${server_id}" C-c + tmux send-keys -t "${session}" C-c log "info" "Sent Exit Request, waiting 10 seconds..." sleep 10 + tmux send-keys -t "${session}" C-d done log "info" "Successfully stopped $(important "${session}")" return 0