Accurate deployment statuses (#168)

This commit is contained in:
Saeed Vaziry
2024-04-21 16:26:26 +02:00
committed by GitHub
parent e2dd9177f7
commit f0da1c6d8c
11 changed files with 88 additions and 35 deletions

View File

@ -127,16 +127,18 @@ public function tail(string $path, int $lines): string
);
}
public function runScript(string $path, string $script, ?int $siteId = null): ServerLog
public function runScript(string $path, string $script, ?ServerLog $serverLog): ServerLog
{
$ssh = $this->server->ssh();
if ($serverLog) {
$ssh->setLog($serverLog);
}
$ssh->exec(
$this->getScript('run-script.sh', [
'path' => $path,
'script' => $script,
]),
'run-script',
$siteId
'run-script'
);
return $ssh->log;

View File

@ -5,6 +5,7 @@
use App\Models\Metric;
use App\SSH\HasScripts;
use App\SSH\Services\AbstractService;
use Closure;
use Illuminate\Support\Facades\Http;
use Illuminate\Validation\Rule;
use Ramsey\Uuid\Uuid;
@ -21,7 +22,12 @@ public function creationRules(array $input): array
{
return [
'type' => [
Rule::unique('services', 'type')->where('server_id', $this->service->server_id),
function (string $attribute, mixed $value, Closure $fail) {
$monitoringExists = $this->service->server->monitoring();
if ($monitoringExists) {
$fail('You already have a monitoring service on the server.');
}
},
],
'version' => [
'required',