mirror of
https://github.com/pelican-dev/panel.git
synced 2025-05-20 15:44:45 +02:00
Improve "no interaction" mode for queue worker service command (#270)
This commit is contained in:
parent
e715e92f9d
commit
422fc102c9
@ -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
|
||||||
|
Loading…
x
Reference in New Issue
Block a user