0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

Ubuntu22.04にsupervisorをインストールしてLaravelプロジェクトのワーカーを作る

Posted at

php artisan queue:workをsupervisorにやってもらう

環境

  • さくらVPS
  • Ubuntu(22.04)
  • nginx(1.26.0)
  • php(8.3.6)
  • Laravel(11.1.0)

手順

supervisor をインストール

sudo apt install supervisor -y

確認

supervisord -v
4.2.1 # バージョン4.2.1がインストールされた

supervisor の自動起動を有効化

sudo systemctl enable supervisor

プロジェクト用のワーカーファイルを作成

sudo vi /etc/supervisor/conf.d/artisan-queue.conf
/etc/supervisor/conf.d/artisan-queue.conf
[program:artisan-queue]
directory=/path/to/your/laravel/project
process_name=%(program_name)s_%(process_num)02d
command=php artisan queue:work --sleep=3 --tries=3
autostart=true
autorestart=true
user=nginx
numprocs=1
redirect_stderr=true
stdout_logfile=/path/to/your/laravel/project/storage/logs/queue/console.log
stderr_logfile=/path/to/your/laravel/project/logs/queue/error.log
startsecs=0
stdout_logfile_maxbytes=0
stderr_logfile_maxbytes=0
stdout_logfile_backups=0
stderr_logfile_backups=0

ログを保存するためのディレクトリを作る

mkdir /path/to/your/laravel/project/storage/logs/queue

作成した.confファイル を読み込む

sudo supervisorctl reread

ワーカーを再起動

sudo supervisorctl reload
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?