我目前正在考虑从 Supervisor 迁移到 Monit,以监视 Laravel 队列工作人员。主要原因是能够监视 CPU、内存和设置电子邮件警报(据主管说,我必须安装另一个软件包),因为我希望尽快监视其他内容,例如 Redis,或许还有 Web 服务器的整体稳定性和性能。
据我对过程监控的有限了解,Monit 更强大并且更适合这项工作。
我能找到的有关 Laravel 和队列/作业监控的所有文档都涉及使用 Supervisor,并且当尝试手动设置它时,我陷入了为队列侦听器设置 pid 文件的困境(我不是系统管理员)。
Laravel 有理由只支持 Supervisor 而根本不提及 Monit 吗? (https://laravel.com/docs/5.3/queues#queue-workers-and-deployment https://laravel.com/docs/5.3/queues#queue-workers-and-deployment)
如果没有 - 有人可以帮助了解如何为每个 Laravel 队列工作程序设置 Monit 配置吗?
假设我有一个项目/var/www/html/laravel
我希望监控的过程是/var/www/html/laravel/artisan queue:work --daemon
我尝试跟随这个问题 https://stackoverflow.com/questions/1226302/how-to-monitor-delayed-job-with-monit但没有取得多大成功。
如果您仍然需要答案:
当然可以设置 Monit 来控制您的队列,但需要注意一点(如他们的常见问题解答 https://mmonit.com/wiki/Monit/FAQ#pidfile);您需要将命令包装在 shell 脚本中。
在Monit配置文件中(在 Ubuntu 14.04 /etc/monit/monitrc 上)你可以添加:
# beanstalk
check process beanstalkd with pidfile /var/run/beanstalkd.pid
start program = "/etc/init.d/beanstalkd start"
stop program = "/etc/init.d/beanstalkd stop"
if failed host 127.0.0.1 port 11300 then restart
if 15 restarts within 15 cycles then timeout
# beanstalk-queue
check process beanstalk-queue with pidfile /var/run/beanstalk-queue.pid
start = "YOUR_CHOSEN_PATH/beanstalk-queue.sh start"
stop = "YOUR_CHOSEN_PATH/beanstalk-queue.sh stop"
然后在 YOUR_CHOSEN_PATH 中创建脚本 beanstalk-queue.sh:
#!/bin/bash
case $1 in
start)
echo $$ > /var/run/beanstalk-queue.pid;
exec 2>&1 php /PATH_TO_YOUR_LARAVEL_INSTALLATION/artisan queue:work --daemon 1>/tmp/beanstalk-queue.out
;;
stop)
kill `cat /var/run/beanstalk-queue.pid` ;;
*)
echo "usage: beanstalk-queue.sh {start|stop}" ;;
esac
exit 0
给它可执行权限就可以了!
聚苯乙烯
我使用的目录适用于 Ubuntu 14.04,请检查其他发行版。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)