From cff54f1969f489edc0e69e3dd9d8f040320c8f67 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 4 Jun 2024 13:01:24 +0200 Subject: [PATCH 1/4] show output when running `p:environment:queue-service` --- app/Console/Commands/Environment/AppSettingsCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/Environment/AppSettingsCommand.php b/app/Console/Commands/Environment/AppSettingsCommand.php index a1d272837..4f2e93119 100644 --- a/app/Console/Commands/Environment/AppSettingsCommand.php +++ b/app/Console/Commands/Environment/AppSettingsCommand.php @@ -118,7 +118,7 @@ class AppSettingsCommand extends Command } if ($this->variables['QUEUE_CONNECTION'] !== 'sync') { - Artisan::call('p:environment:queue-service', [ + $this->call('p:environment:queue-service', [ '--use-redis' => $redisUsed, ]); } From d81c9faac60a57c2548422bd9966c7d20b1a99aa Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 4 Jun 2024 13:01:52 +0200 Subject: [PATCH 2/4] improve prompts --- .../Commands/Environment/QueueWorkerServiceCommand.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index 49d4cbfec..3fe3da4c9 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -19,7 +19,7 @@ class QueueWorkerServiceCommand extends Command public function handle(): void { - $serviceName = $this->option('service-name') ?? $this->ask('Service name', 'pelican-queue'); + $serviceName = $this->option('service-name') ?? $this->ask('Queue worker Service name', 'pelican-queue'); $path = '/etc/systemd/system/' . $serviceName . '.service'; if (file_exists($path) && !$this->option('overwrite') && !$this->confirm('The service file already exists. Do you want to overwrite it?')) { @@ -28,8 +28,8 @@ class QueueWorkerServiceCommand extends Command return; } - $user = $this->option('user') ?? $this->ask('User', 'www-data'); - $group = $this->option('group') ?? $this->ask('Group', 'www-data'); + $user = $this->option('user') ?? $this->ask('Webserver User', 'www-data'); + $group = $this->option('group') ?? $this->ask('Webserver Group', 'www-data'); $afterRedis = $this->option('use-redis') ? '\nAfter=redis-server.service' : ''; From 07282668264265f5478dd0916565fd3d659eeac4 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 4 Jun 2024 13:14:54 +0200 Subject: [PATCH 3/4] restart queue service if service already exists --- .../Environment/QueueWorkerServiceCommand.php | 30 +++++++++++++------ 1 file changed, 21 insertions(+), 9 deletions(-) diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index 3fe3da4c9..68f2c6750 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -19,11 +19,12 @@ class QueueWorkerServiceCommand extends Command public function handle(): void { - $serviceName = $this->option('service-name') ?? $this->ask('Queue worker Service name', 'pelican-queue'); + $serviceName = $this->option('service-name') ?? $this->ask('Queue worker service name', 'pelican-queue'); $path = '/etc/systemd/system/' . $serviceName . '.service'; - 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.'); + $fileExists = file_exists($path); + if ($fileExists && !$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 because serive file already exists.'); return; } @@ -60,13 +61,24 @@ WantedBy=multi-user.target return; } - $result = Process::run("systemctl enable --now $serviceName.service"); - if ($result->failed()) { - $this->error('Error enabling service: ' . $result->errorOutput()); + if ($fileExists) { + $result = Process::run("systemctl restart $serviceName.service"); + if ($result->failed()) { + $this->error('Error restarting service: ' . $result->errorOutput()); - return; + return; + } + + $this->line('Queue worker service file updated successfully.'); + } else { + $result = Process::run("systemctl enable --now $serviceName.service"); + if ($result->failed()) { + $this->error('Error enabling service: ' . $result->errorOutput()); + + return; + } + + $this->line('Queue worker service file created successfully.'); } - - $this->line('Queue worker service file created successfully.'); } } From bb03ddda5040f826cd3bcb6d4e863e27a7783645 Mon Sep 17 00:00:00 2001 From: Boy132 Date: Tue, 4 Jun 2024 17:26:19 +0200 Subject: [PATCH 4/4] listen on all queues --- app/Console/Commands/Environment/QueueWorkerServiceCommand.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php index 68f2c6750..93fe6223f 100644 --- a/app/Console/Commands/Environment/QueueWorkerServiceCommand.php +++ b/app/Console/Commands/Environment/QueueWorkerServiceCommand.php @@ -46,7 +46,7 @@ Description=Pelican Queue Service$afterRedis User=$user Group=$group Restart=always -ExecStart=/usr/bin/php $basePath/artisan queue:work --queue=high,standard,low --tries=3 +ExecStart=/usr/bin/php $basePath/artisan queue:work --tries=3 StartLimitInterval=180 StartLimitBurst=30 RestartSec=5s