chore: prepare for PR
This commit is contained in:
parent
b566889782
commit
f05b7106cf
1 changed files with 6 additions and 46 deletions
|
|
@ -113,16 +113,14 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
|
||||||
$nginxconf_base64 = base64_encode($nginxconf);
|
$nginxconf_base64 = base64_encode($nginxconf);
|
||||||
instant_remote_process(["docker rm -f $proxyContainerName"], $server, false);
|
instant_remote_process(["docker rm -f $proxyContainerName"], $server, false);
|
||||||
|
|
||||||
try {
|
|
||||||
|
|
||||||
try {
|
try {
|
||||||
instant_remote_process([
|
instant_remote_process([
|
||||||
"mkdir -p $configuration_dir",
|
"mkdir -p $configuration_dir",
|
||||||
"echo '{$nginxconf_base64}' | base64 -d | tee $configuration_dir/nginx.conf > /dev/null",
|
"echo '{$nginxconf_base64}' | base64 -d | tee $configuration_dir/nginx.conf > /dev/null",
|
||||||
"echo '{$dockercompose_base64}' | base64 -d | tee $configuration_dir/docker-compose.yaml > /dev/null",
|
"echo '{$dockercompose_base64}' | base64 -d | tee $configuration_dir/docker-compose.yaml > /dev/null",
|
||||||
"docker compose --project-directory {$configuration_dir} pull",
|
"docker compose --project-directory {$configuration_dir} pull",
|
||||||
"docker compose --project-directory {$configuration_dir} up -d",
|
"docker compose --project-directory {$configuration_dir} up -d",
|
||||||
], $server);
|
], $server);
|
||||||
} catch (\RuntimeException $e) {
|
} catch (\RuntimeException $e) {
|
||||||
if ($this->isNonTransientError($e->getMessage())) {
|
if ($this->isNonTransientError($e->getMessage())) {
|
||||||
$database->update(['is_public' => false]);
|
$database->update(['is_public' => false]);
|
||||||
|
|
@ -146,44 +144,6 @@ public function handle(StandaloneRedis|StandalonePostgresql|StandaloneMongodb|St
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private function isNonTransientError(string $message): bool
|
|
||||||
{
|
|
||||||
$nonTransientPatterns = [
|
|
||||||
'port is already allocated',
|
|
||||||
'address already in use',
|
|
||||||
'Bind for',
|
|
||||||
];
|
|
||||||
|
|
||||||
foreach ($nonTransientPatterns as $pattern) {
|
|
||||||
if (str_contains($message, $pattern)) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
} catch (\RuntimeException $e) {
|
|
||||||
if ($this->isNonTransientError($e->getMessage())) {
|
|
||||||
$database->update(['is_public' => false]);
|
|
||||||
|
|
||||||
$team = data_get($database, 'environment.project.team')
|
|
||||||
?? data_get($database, 'service.environment.project.team');
|
|
||||||
|
|
||||||
$team?->notify(
|
|
||||||
new \App\Notifications\Container\ContainerRestarted(
|
|
||||||
"TCP Proxy for {$database->name} was disabled due to error: {$e->getMessage()}",
|
|
||||||
$server,
|
|
||||||
)
|
|
||||||
);
|
|
||||||
|
|
||||||
ray("Database proxy for {$database->name} disabled due to non-transient error: {$e->getMessage()}");
|
|
||||||
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
throw $e;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private function isNonTransientError(string $message): bool
|
private function isNonTransientError(string $message): bool
|
||||||
{
|
{
|
||||||
$nonTransientPatterns = [
|
$nonTransientPatterns = [
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue