Improve "no interaction" mode for queue worker service command (#270)

This commit is contained in:
Boy132 2024-05-26 02:48:02 +02:00 committed by GitHub
parent e715e92f9d
commit 422fc102c9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

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();