Created
July 14, 2025 23:59
-
-
Save wallacemaxters/fa57797cd44e8a41845947d52aaecc9b to your computer and use it in GitHub Desktop.
Laravel command to install queue as Linux service
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
use Illuminate\Foundation\Inspiring; | |
use Illuminate\Support\Facades\Artisan; | |
use Illuminate\Support\Facades\Process; | |
Artisan::command('app:queue-service-install', function () { | |
$content = file_get_contents(base_path('stubs/queue.service.stub')); | |
$content = strtr($content, ['{{ $dir }}' => base_path()]); | |
file_put_contents('/etc/systemd/system/laravel-queue.service', $content); | |
Process::run('systemctl daemon-reload'); | |
Process::run('systemctl enable laravel-queue.service'); | |
Process::run('systemctl start laravel-queue.service'); | |
}); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Laravel queue worker using systemd | |
# ---------------------------------- | |
[Unit] | |
Description=Laravel Queue Work | |
[Service] | |
User=www-data | |
Group=www-data | |
Restart=always | |
WorkingDirectory={{ $dir }} | |
ExecStart=/usr/bin/php artisan queue:work --sleep=3 --tries=3 | |
[Install] | |
WantedBy=multi-user.target |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment