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,15 +14,17 @@ class QueueWorkerServiceCommand extends Command
{--service-name= : Name of the queue worker service.}
{--user= : The user 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
{
$serviceName = $this->option('service-name') ?? $this->ask('Service name', 'pelican-queue');
$path = '/etc/systemd/system/' . $serviceName . '.service';
if ($this->input->isInteractive()) {
if (file_exists($path) && !$this->confirm('The service file already exists. Do you want to overwrite it?')) {
if (file_exists($path) && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) {
$this->line('Creation of queue worker service file aborted.');
return;
}
@ -30,12 +32,6 @@ class QueueWorkerServiceCommand extends Command
$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 = '';
}
$basePath = base_path();

View File

@ -5,7 +5,6 @@ namespace App\Transformers\Api\Application;
use Illuminate\Support\Arr;
use App\Models\Egg;
use App\Models\Server;
use League\Fractal\Resource\Item;
use App\Models\EggVariable;
use League\Fractal\Resource\Collection;
use League\Fractal\Resource\NullResource;
@ -39,7 +38,11 @@ class EggTransformer extends BaseTransformer
*/
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 [
'id' => $model->id,
@ -54,18 +57,18 @@ class EggTransformer extends BaseTransformer
'docker_images' => $model->docker_images,
'config' => [
'files' => $files,
'startup' => json_decode($model->config_startup, true),
'stop' => $model->config_stop,
'logs' => json_decode($model->config_logs, true),
'file_denylist' => $model->file_denylist,
'startup' => json_decode($model->inherit_config_startup, true),
'stop' => $model->inherit_config_stop,
'logs' => json_decode($model->inherit_config_logs, true),
'file_denylist' => $model->inherit_file_denylist,
'extends' => $model->config_from,
],
'startup' => $model->startup,
'script' => [
'privileged' => $model->script_is_privileged,
'install' => $model->script_install,
'entry' => $model->script_entry,
'container' => $model->script_container,
'install' => $model->copy_script_install,
'entry' => $model->copy_script_entry,
'container' => $model->copy_script_container,
'extends' => $model->copy_script_from,
],
$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);
}
/**
* 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.
*