fix: respect start period and chekc interval for hc

This commit is contained in:
Andras Bacsai 2024-04-29 12:55:38 +02:00
parent 0c516843d8
commit 05c6d67cab

View File

@ -914,6 +914,12 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
if ($this->full_healthcheck_url) { if ($this->full_healthcheck_url) {
$this->application_deployment_queue->addLogEntry("Healthcheck URL (inside the container): {$this->full_healthcheck_url}"); $this->application_deployment_queue->addLogEntry("Healthcheck URL (inside the container): {$this->full_healthcheck_url}");
} }
$this->application_deployment_queue->addLogEntry("Waiting for the start period ({$this->application->health_check_start_period} seconds) before starting healthcheck.");
$sleeptime = 0;
while ($sleeptime < $this->application->health_check_start_period) {
Sleep::for(1)->seconds();
$sleeptime++;
}
while ($counter <= $this->application->health_check_retries) { while ($counter <= $this->application->health_check_retries) {
$this->execute_remote_command( $this->execute_remote_command(
[ [
@ -936,7 +942,11 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
break; break;
} }
$counter++; $counter++;
Sleep::for($this->application->health_check_interval)->seconds(); $sleeptime = 0;
while ($sleeptime < $this->application->health_check_interval) {
Sleep::for(1)->seconds();
$sleeptime++;
}
} }
} }
} }
@ -1595,10 +1605,10 @@ class ApplicationDeploymentJob implements ShouldQueue, ShouldBeEncrypted
private function generate_healthcheck_commands() private function generate_healthcheck_commands()
{ {
if ($this->application->dockerfile || $this->application->build_pack === 'dockerfile' || $this->application->build_pack === 'dockerimage') { // if ($this->application->dockerfile || $this->application->build_pack === 'dockerfile' || $this->application->build_pack === 'dockerimage') {
// TODO: disabled HC because there are several ways to hc a simple docker image, hard to figure out a good way. Like some docker images (pocketbase) does not have curl. // // TODO: disabled HC because there are several ways to hc a simple docker image, hard to figure out a good way. Like some docker images (pocketbase) does not have curl.
return 'exit 0'; // return 'exit 0';
} // }
if (!$this->application->health_check_port) { if (!$this->application->health_check_port) {
$health_check_port = $this->application->ports_exposes_array[0]; $health_check_port = $this->application->ports_exposes_array[0];
} else { } else {