Skip to content

Instantly share code, notes, and snippets.

@masiur
Forked from ratul0/instruction.md
Created December 18, 2017 09:14
Show Gist options
  • Save masiur/9c1c0312dd815b723a55e7682b75e4e4 to your computer and use it in GitHub Desktop.
Save masiur/9c1c0312dd815b723a55e7682b75e4e4 to your computer and use it in GitHub Desktop.
Laravel mail with supervisor

Frist run this migrations :

php artisan queue:table

php artisan queue:failed-table

php artisan migrate

create a job using artisan

php artisan make:job TestJob --queued

Then dispatch the job when appropriate

$job = (new TestJob($user))->delay(10);
$this->dispatch($job);

Create a "laravel-worker.conf" in /etc/supervisor/conf.d folder

[program:laravel-worker]
process_name=%(program_name)s_%(process_num)02d
command=php /var/www/html/app/artisan queue:work database --sleep=3 --tries=3 --daemon
autostart=true
autorestart=true
user=www-data
numprocs=8
redirect_stderr=true
stdout_logfile=/var/www/html/app/worker.log

After saving the file run these commands

sudo supervisorctl reread

sudo supervisorctl update

sudo supervisorctl start laravel-worker:*
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment