This commit is contained in:
Andras Bacsai
2023-05-15 13:45:37 +02:00
parent 845a8e5076
commit ec3ae7f6de
13 changed files with 280 additions and 173 deletions

View File

@@ -67,9 +67,7 @@ class ContainerStatusJob implements ShouldQueue
return;
}
if ($application->destination->server) {
$container = instantRemoteProcess(["docker inspect --format '{{json .State}}' {$this->container_id}"], $application->destination->server);
$container = formatDockerCmdOutputToJson($container);
$application->status = $container[0]['Status'];
$application->status = checkContainerStatus(server: $application->destination->server, container_id: $this->container_id);
$application->save();
}
}

View File

@@ -69,7 +69,6 @@ class DeployApplicationJob implements ShouldQueue
protected function stopRunningContainer()
{
$this->executeNow([
"echo -n 'Removing old instance... '",
$this->execute_in_builder("docker rm -f {$this->application->uuid} >/dev/null 2>&1"),
"echo 'Done.'",

45
app/Jobs/ProxyCheckJob.php Executable file
View File

@@ -0,0 +1,45 @@
<?php
namespace App\Jobs;
use App\Actions\Proxy\InstallProxy;
use App\Models\Server;
use Illuminate\Bus\Queueable;
use Illuminate\Contracts\Queue\ShouldQueue;
use Illuminate\Foundation\Bus\Dispatchable;
use Illuminate\Queue\InteractsWithQueue;
use Illuminate\Queue\SerializesModels;
class ProxyCheckJob implements ShouldQueue
{
use Dispatchable, InteractsWithQueue, Queueable, SerializesModels;
/**
* Create a new job instance.
*/
public function __construct()
{
}
/**
* Execute the job.
*/
public function handle()
{
try {
$container_name = 'coolify-proxy';
$configuration_path = config('coolify.proxy_config_path');
$servers = Server::whereRelation('settings', 'is_validated', true)->get();
foreach ($servers as $server) {
$status = checkContainerStatus(server: $server, container_id: $container_name);
if ($status === 'running') {
continue;
}
resolve(InstallProxy::class)($server);
}
} catch (\Throwable $th) {
//throw $th;
}
}
}