Laravel:运行队列:在 Windows Azure Web App 上连续监听
问题描述
我觉得问这个问题有点傻,但我似乎无法在互联网上找到这个问题的答案.搜索了几个小时后,我发现在 linux 服务器上,您使用 Supervisor 在您的网站上连续运行php artisan queue:listen"(有或没有守护程序)来处理推送到队列的作业.这一切都很好,但是如果我想在 Windows Azure Web 应用程序上执行此操作怎么办?在搜索了我发现的解决方案后:
I feel a little bit silly for asking this question but I can't seem to find an answer on the internet for this problem. After searching for several hours I figured out that on a linux server you use Supervisor to run "php artisan queue:listen" (either with or without daemon) continuously on your website to handle jobs pushed to the queue. This is all well and good, but what if I want to do this on a Windows Azure web app? After searching around the solutions I found were:
- 做一个定时作业,每分钟(或每 X 分钟)运行一次php artisan queue:listen",我真的不喜欢这个解决方案,如果网站获得更多流量,我想特别避免它;
- 添加一个连续运行php artisan queue:listen"的WebJob(这里的问题是我不知道如何为WebJob编写脚本...);
我想请你们帮忙看看哪些是正确的解决方案,是否有更好的解决方案,如果 WebJob 是最好的解决方案,我该如何为此编写脚本?提前致谢.
I want to ask you guys for help on to know which of these is the correct solution, if there is a better one and if the WebJob is the best one how do I write the script for this? Thanks in advance.
推荐答案
简而言之,Supervisor 是 nohup(不挂断)的现代替代品,并添加了一些其他零碎的东西.简而言之,还有其他资源可以让任务在后台运行(守护进程),而我用于基于 Windows 的项目(很少 tbh)的解决方案是 Forever,我通过以下方式发现:https://stackoverflow.com/a/18226392/5912664
In short, Supervisor is a modern alternative to nohup (no hang up) with a few other bits and pieces tacked on. In short, there's other resources that can keep a task running in the background (daemon) and the solution I use for Windows based projects (very few tbh) is Forever which I discovered via: https://stackoverflow.com/a/18226392/5912664
怎么做?
为 Windows 安装 node
,然后使用 npm
安装 Forever
Install node
for Windows, then with npm
install Forever
如果您无法在 Windows 上运行 Node,我建议您使用 Windows 包管理器 Chocolatey
If you're stuck for getting Node running on Windows, I recommend the Windows Package Manager, Chocolatey
https://chocolatey.org/packages?q=node
请务必检查 Forever
创建的任何日志文件,因为我留下的日志文件足够长,足以占用 30Gb 的磁盘空间!
Be sure to check for any logfiles that Forever
creates, as I had left one long enough to consume 30Gb of disk space!
这篇关于Laravel:运行队列:在 Windows Azure Web App 上连续监听的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!