Add 60-second wait and process verification to restart operations for reliable scheduler functionality

Co-authored-by: iaretechnician <2749183+iaretechnician@users.noreply.github.com>
This commit is contained in:
copilot-swe-agent[bot] 2025-09-10 19:40:37 +00:00
parent d026b436d8
commit f6bb183cb4
4 changed files with 116 additions and 0 deletions

View file

@ -2826,6 +2826,36 @@ sub restart_server_without_decrypt
$server_port, $control_protocol,
$control_password, $control_type, $home_path) == 0)
{
# Wait for processes to be completely terminated and verify they are killed
logger "Waiting for server processes to terminate completely...";
my $max_wait_attempts = 30; # 30 seconds max to wait for processes to die
my $wait_count = 0;
while ($wait_count < $max_wait_attempts)
{
my @remaining_pids = get_home_pids($home_id);
if (@remaining_pids == 0)
{
logger "All server processes have been terminated successfully.";
last;
}
$wait_count++;
logger "Waiting for processes to terminate... (attempt $wait_count/$max_wait_attempts, PIDs: @remaining_pids)";
sleep 1;
}
# Final check - if processes still exist, log warning but continue
my @final_check_pids = get_home_pids($home_id);
if (@final_check_pids > 0)
{
logger "Warning: Some processes may still be running (PIDs: @final_check_pids), but proceeding with restart.";
}
# Wait 60 seconds between stop and start operations as requested
logger "Waiting 60 seconds before starting server as requested for reliable scheduler functionality...";
sleep 60;
if (universal_start_without_decrypt($home_id, $home_path, $server_exe, $run_dir,
$cmd, $server_port, $server_ip, $cpu, $nice, $preStart, $envVars, $game_key, $console_log) == 1)
{

View file

@ -2461,6 +2461,34 @@ sub restart_server_without_decrypt
$server_port, $control_protocol,
$control_password, $control_type, $home_path) == 0)
{
# Wait for screen session to be completely terminated and verify it has stopped
logger "Waiting for server screen session to terminate completely...";
my $max_wait_attempts = 30; # 30 seconds max to wait for screen to die
my $wait_count = 0;
while ($wait_count < $max_wait_attempts)
{
if (is_screen_running_without_decrypt(SCREEN_TYPE_HOME, $home_id) == 0)
{
logger "Server screen session has been terminated successfully.";
last;
}
$wait_count++;
logger "Waiting for screen session to terminate... (attempt $wait_count/$max_wait_attempts)";
sleep 1;
}
# Final check - if screen still exists, log warning but continue
if (is_screen_running_without_decrypt(SCREEN_TYPE_HOME, $home_id) == 1)
{
logger "Warning: Server screen session may still be running, but proceeding with restart.";
}
# Wait 60 seconds between stop and start operations as requested
logger "Waiting 60 seconds before starting server as requested for reliable scheduler functionality...";
sleep 60;
if (universal_start_without_decrypt($home_id, $home_path, $server_exe, $run_dir,
$cmd, $server_port, $server_ip, $cpu, $nice, $preStart, $envVars, $game_key, $console_log) == 1)
{

View file

@ -2826,6 +2826,36 @@ sub restart_server_without_decrypt
$server_port, $control_protocol,
$control_password, $control_type, $home_path) == 0)
{
# Wait for processes to be completely terminated and verify they are killed
logger "Waiting for server processes to terminate completely...";
my $max_wait_attempts = 30; # 30 seconds max to wait for processes to die
my $wait_count = 0;
while ($wait_count < $max_wait_attempts)
{
my @remaining_pids = get_home_pids($home_id);
if (@remaining_pids == 0)
{
logger "All server processes have been terminated successfully.";
last;
}
$wait_count++;
logger "Waiting for processes to terminate... (attempt $wait_count/$max_wait_attempts, PIDs: @remaining_pids)";
sleep 1;
}
# Final check - if processes still exist, log warning but continue
my @final_check_pids = get_home_pids($home_id);
if (@final_check_pids > 0)
{
logger "Warning: Some processes may still be running (PIDs: @final_check_pids), but proceeding with restart.";
}
# Wait 60 seconds between stop and start operations as requested
logger "Waiting 60 seconds before starting server as requested for reliable scheduler functionality...";
sleep 60;
if (universal_start_without_decrypt($home_id, $home_path, $server_exe, $run_dir,
$cmd, $server_port, $server_ip, $cpu, $nice, $preStart, $envVars, $game_key, $console_log) == 1)
{

View file

@ -2461,6 +2461,34 @@ sub restart_server_without_decrypt
$server_port, $control_protocol,
$control_password, $control_type, $home_path) == 0)
{
# Wait for screen session to be completely terminated and verify it has stopped
logger "Waiting for server screen session to terminate completely...";
my $max_wait_attempts = 30; # 30 seconds max to wait for screen to die
my $wait_count = 0;
while ($wait_count < $max_wait_attempts)
{
if (is_screen_running_without_decrypt(SCREEN_TYPE_HOME, $home_id) == 0)
{
logger "Server screen session has been terminated successfully.";
last;
}
$wait_count++;
logger "Waiting for screen session to terminate... (attempt $wait_count/$max_wait_attempts)";
sleep 1;
}
# Final check - if screen still exists, log warning but continue
if (is_screen_running_without_decrypt(SCREEN_TYPE_HOME, $home_id) == 1)
{
logger "Warning: Server screen session may still be running, but proceeding with restart.";
}
# Wait 60 seconds between stop and start operations as requested
logger "Waiting 60 seconds before starting server as requested for reliable scheduler functionality...";
sleep 60;
if (universal_start_without_decrypt($home_id, $home_path, $server_exe, $run_dir,
$cmd, $server_port, $server_ip, $cpu, $nice, $preStart, $envVars, $game_key, $console_log) == 1)
{