Merge branch 'main' of github.com:pelican-dev/panel

This commit is contained in:
Lance Pioch 2024-05-25 20:59:54 -04:00
commit a8b2fb440f
2 changed files with 22 additions and 67 deletions

View File

@ -14,29 +14,25 @@ class QueueWorkerServiceCommand extends Command
{--service-name= : Name of the queue worker service.} {--service-name= : Name of the queue worker service.}
{--user= : The user that PHP runs under.} {--user= : The user that PHP runs under.}
{--group= : The group that PHP runs under.} {--group= : The group that PHP runs under.}
{--use-redis : Whether redis is used.}'; {--use-redis : Whether redis is used.}
{--overwrite : Force overwrite if the service file already exists.}';
public function handle(): void public function handle(): void
{ {
$serviceName = $this->option('service-name') ?? $this->ask('Service name', 'pelican-queue'); $serviceName = $this->option('service-name') ?? $this->ask('Service name', 'pelican-queue');
$path = '/etc/systemd/system/' . $serviceName . '.service'; $path = '/etc/systemd/system/' . $serviceName . '.service';
if ($this->input->isInteractive()) { if (file_exists($path) && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) {
if (file_exists($path) && !$this->confirm('The service file already exists. Do you want to overwrite it?')) { $this->line('Creation of queue worker service file aborted.');
return;
}
$user = $this->option('user') ?? $this->ask('User', 'www-data'); return;
$group = $this->option('group') ?? $this->ask('Group', 'www-data');
$afterRedis = $this->option('use-redis') ? '\nAfter=redis-server.service' : '';
} else {
$user = 'www-data';
$group = 'www-data';
$afterRedis = '';
} }
$user = $this->option('user') ?? $this->ask('User', 'www-data');
$group = $this->option('group') ?? $this->ask('Group', 'www-data');
$afterRedis = $this->option('use-redis') ? '\nAfter=redis-server.service' : '';
$basePath = base_path(); $basePath = base_path();
$success = File::put($path, "# Pelican Queue File $success = File::put($path, "# Pelican Queue File

View File

@ -5,7 +5,6 @@ namespace App\Transformers\Api\Application;
use Illuminate\Support\Arr; use Illuminate\Support\Arr;
use App\Models\Egg; use App\Models\Egg;
use App\Models\Server; use App\Models\Server;
use League\Fractal\Resource\Item;
use App\Models\EggVariable; use App\Models\EggVariable;
use League\Fractal\Resource\Collection; use League\Fractal\Resource\Collection;
use League\Fractal\Resource\NullResource; use League\Fractal\Resource\NullResource;
@ -39,7 +38,11 @@ class EggTransformer extends BaseTransformer
*/ */
public function transform(Egg $model): array public function transform(Egg $model): array
{ {
$files = json_decode($model->config_files, true, 512, JSON_THROW_ON_ERROR); $model->loadMissing('configFrom');
$files = json_decode($model->inherit_config_files, true, 512, JSON_THROW_ON_ERROR);
$model->loadMissing('scriptFrom');
return [ return [
'id' => $model->id, 'id' => $model->id,
@ -54,18 +57,18 @@ class EggTransformer extends BaseTransformer
'docker_images' => $model->docker_images, 'docker_images' => $model->docker_images,
'config' => [ 'config' => [
'files' => $files, 'files' => $files,
'startup' => json_decode($model->config_startup, true), 'startup' => json_decode($model->inherit_config_startup, true),
'stop' => $model->config_stop, 'stop' => $model->inherit_config_stop,
'logs' => json_decode($model->config_logs, true), 'logs' => json_decode($model->inherit_config_logs, true),
'file_denylist' => $model->file_denylist, 'file_denylist' => $model->inherit_file_denylist,
'extends' => $model->config_from, 'extends' => $model->config_from,
], ],
'startup' => $model->startup, 'startup' => $model->startup,
'script' => [ 'script' => [
'privileged' => $model->script_is_privileged, 'privileged' => $model->script_is_privileged,
'install' => $model->script_install, 'install' => $model->copy_script_install,
'entry' => $model->script_entry, 'entry' => $model->copy_script_entry,
'container' => $model->script_container, 'container' => $model->copy_script_container,
'extends' => $model->copy_script_from, 'extends' => $model->copy_script_from,
], ],
$model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at), $model->getCreatedAtColumn() => $this->formatTimestamp($model->created_at),
@ -89,50 +92,6 @@ class EggTransformer extends BaseTransformer
return $this->collection($model->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME); return $this->collection($model->getRelation('servers'), $this->makeTransformer(ServerTransformer::class), Server::RESOURCE_NAME);
} }
/**
* Include more detailed information about the configuration if this Egg is
* extending another.
*/
public function includeConfig(Egg $model): Item|NullResource
{
if (is_null($model->config_from)) {
return $this->null();
}
$model->loadMissing('configFrom');
return $this->item($model, function (Egg $model) {
return [
'files' => json_decode($model->inherit_config_files),
'startup' => json_decode($model->inherit_config_startup),
'stop' => $model->inherit_config_stop,
'logs' => json_decode($model->inherit_config_logs),
];
});
}
/**
* Include more detailed information about the script configuration if the
* Egg is extending another.
*/
public function includeScript(Egg $model): Item|NullResource
{
if (is_null($model->copy_script_from)) {
return $this->null();
}
$model->loadMissing('scriptFrom');
return $this->item($model, function (Egg $model) {
return [
'privileged' => $model->script_is_privileged,
'install' => $model->copy_script_install,
'entry' => $model->copy_script_entry,
'container' => $model->copy_script_container,
];
});
}
/** /**
* Include the variables that are defined for this Egg. * Include the variables that are defined for this Egg.
* *