- package updates
- feat: service fixes - ui: help menu
This commit is contained in:
@@ -1,6 +1,8 @@
|
||||
<?php
|
||||
|
||||
use App\Models\Service;
|
||||
use App\Models\ServiceApplication;
|
||||
use App\Models\ServiceDatabase;
|
||||
use Illuminate\Support\Str;
|
||||
|
||||
function replaceRegex(?string $name = null)
|
||||
@@ -43,4 +45,32 @@ function serviceStatus(Service $service)
|
||||
} else if (!$foundRunning && $isDegraded) {
|
||||
return 'exited';
|
||||
}
|
||||
return 'exited';
|
||||
}
|
||||
function saveFileVolumesHelper(ServiceApplication|ServiceDatabase $oneService)
|
||||
{
|
||||
try {
|
||||
$workdir = $oneService->service->workdir();
|
||||
$server = $oneService->service->server;
|
||||
$applicationFileVolume = $oneService->fileStorages()->get();
|
||||
$commands = collect([
|
||||
"mkdir -p $workdir",
|
||||
"cd $workdir"
|
||||
]);
|
||||
foreach ($applicationFileVolume as $fileVolume) {
|
||||
$content = $fileVolume->content;
|
||||
$path = Str::of($fileVolume->fs_path);
|
||||
$dir = $path->beforeLast('/');
|
||||
if ($dir->startsWith('.')) {
|
||||
$dir = $dir->after('.');
|
||||
$dir = $workdir . $dir;
|
||||
}
|
||||
$content = base64_encode($content);
|
||||
$commands->push("mkdir -p $dir");
|
||||
$commands->push("echo '$content' | base64 -d > $path");
|
||||
}
|
||||
return instant_remote_process($commands, $server);
|
||||
} catch (\Throwable $e) {
|
||||
return handleError($e);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user