2023-09-21 17:48:31 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace App\Actions\Service;
|
|
|
|
|
|
|
|
use Lorisleiva\Actions\Concerns\AsAction;
|
|
|
|
use App\Models\Service;
|
|
|
|
|
|
|
|
class StartService
|
|
|
|
{
|
|
|
|
use AsAction;
|
|
|
|
public function handle(Service $service)
|
|
|
|
{
|
2023-09-25 12:49:55 +02:00
|
|
|
$service->saveComposeConfigs();
|
|
|
|
$commands[] = "cd " . $service->workdir();
|
2023-09-26 14:45:52 +02:00
|
|
|
$commands[] = "echo '####### Saved configuration files to {$service->workdir()}.'";
|
2023-09-22 14:47:25 +02:00
|
|
|
$commands[] = "echo '####### Starting service {$service->name} on {$service->server->name}.'";
|
2023-09-22 20:39:56 +02:00
|
|
|
$commands[] = "echo '####### Pulling images.'";
|
2023-09-25 15:48:43 +02:00
|
|
|
$commands[] = "docker compose pull";
|
2023-09-22 14:47:25 +02:00
|
|
|
$commands[] = "echo '####### Starting containers.'";
|
2023-09-27 12:45:53 +02:00
|
|
|
$commands[] = "docker compose up -d --remove-orphans";
|
2023-09-21 21:30:13 +02:00
|
|
|
$commands[] = "docker network connect $service->uuid coolify-proxy 2>/dev/null || true";
|
2023-09-21 17:48:31 +02:00
|
|
|
$activity = remote_process($commands, $service->server);
|
|
|
|
return $activity;
|
|
|
|
}
|
|
|
|
}
|