Handle no connection to the docker socket better

This commit is contained in:
Greyscale 2021-06-07 00:08:49 +02:00
parent cf2744a175
commit 92708c01dc
2 changed files with 14 additions and 2 deletions

View file

@ -289,7 +289,12 @@ class Bouncer
public function run(): void
{
$this->logger->info(sprintf('%s Starting Bouncer...', Emoji::CHARACTER_TIMER_CLOCK));
$this->stateHasChanged();
try {
$this->stateHasChanged();
}catch(\GuzzleHttp\Exception\ConnectException $connectException){
$this->logger->critical(sprintf("%s Could not connect to docker socket! Did you map it?", Emoji::CHARACTER_CRYING_CAT));
exit;
}
while (true) {
$this->runLoop();
}
@ -373,6 +378,10 @@ class Bouncer
/** @var FileAttributes $newLocalCert */
if ($newLocalCert->isFile() && pathinfo($newLocalCert->path(), PATHINFO_EXTENSION) == 'pem') {
$livePath = str_replace('archive/', 'live/', $newLocalCert->path());
// Stupid dirty hack bullshit reee
for($i = 1; $i <= 9; $i++){
$livePath = str_replace("$i.pem", ".pem", $livePath);
}
$this->certificateStoreLocal->writeStream($livePath, $this->certificateStoreLocal->readStream($newLocalCert->path()));
}
}
@ -413,7 +422,7 @@ class Bouncer
$target->getName(),
$this->twig->render('NginxTemplate.twig', $target->__toArray())
);
$this->logger->info(sprintf('%s Created config for %s', Emoji::CHARACTER_PENCIL, $target->getName()));
$this->logger->info(sprintf('%s Created Nginx config for %s', Emoji::CHARACTER_PENCIL, $target->getName()));
return $this;
}
@ -442,6 +451,8 @@ class Bouncer
round($timeRemainingSeconds / 86400)
));
$target->setUseTemporaryCert(false);
$this->generateNginxConfig($target);
continue;
}
}

View file

@ -1,3 +1,4 @@
#!/usr/bin/env bash
echo "Starting Bouncer"
/app/bouncer
sleep 60;