Server: include uptime in crash restart throttle message

this makes it clearer why the wait duration is chosen instead of it looking random.
This commit is contained in:
Dylan K. Taylor 2024-04-29 16:36:14 +01:00
parent d70a7d34a7
commit ed158f8a1b
No known key found for this signature in database
GPG Key ID: 8927471A91CAFD3D

View File

@ -1666,9 +1666,11 @@ class Server{
$this->isRunning = false; $this->isRunning = false;
//Force minimum uptime to be >= 120 seconds, to reduce the impact of spammy crash loops //Force minimum uptime to be >= 120 seconds, to reduce the impact of spammy crash loops
$spacing = ((int) $this->startTime) - time() + 120; $uptime = time() - ((int) $this->startTime);
$minUptime = 120;
$spacing = $minUptime - $uptime;
if($spacing > 0){ if($spacing > 0){
echo "--- Waiting $spacing seconds to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL; echo "--- Uptime {$uptime}s - waiting {$spacing}s to throttle automatic restart (you can kill the process safely now) ---" . PHP_EOL;
sleep($spacing); sleep($spacing);
} }
@Process::kill(Process::pid()); @Process::kill(Process::pid());