JoshuaBedford/laravel-lando

Restart queue worker on file changes

Closed this issue ยท 1 comments

divdax commented

Hey! ๐Ÿ‘‹

Thank your for this repository. Do you know how I can make the queue restart automatically when I make changes to a file? Any ideas would be cool!

divdax commented

I finally got a working version. I'm using Laravel Horizon to work with queues.

nodemon: run command on .php file changes
nohup: run nodemon as background process

.lando.yml

services:
  appserver:
    build_as_root:
      - apt update -y
      - apt install -y supervisor
      - npm install -g nodemon
      - cp -f /app/.lando/docker-php-entrypoint.sh /usr/local/bin/docker-php-entrypoint
      - cp -f /app/.lando/horizon.conf /etc/supervisor/conf.d/horizon.conf
    run_as_root:
      - service supervisor start
      - supervisorctl start horizon
      - nohup /usr/bin/nodemon --exec /usr/local/bin/php artisan horizon:terminate -e php

horizon.conf

[program:horizon]
process_name=%(program_name)s
command=php /app/artisan horizon
autostart=true
autorestart=true
user=root
redirect_stderr=true
stdout_logfile=/app/storage/logs/worker.log
stopwaitsecs=3600