Laravel:运行队列:在 Windows Azure Web 应用程序上持续监听

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37729662/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 13:58:12  来源:igfitidea点击:

Laravel: Running queue:listen continuously on Windows Azure Web App

phplaravelazurequeueartisan

提问by Tiago Magalh?es

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:

问这个问题我觉得有点傻,但我似乎无法在互联网上找到这个问题的答案。搜索了几个小时后,我发现在 Linux 服务器上,您使用 Supervisor 在您的网站上连续运行“php artisan queue:listen”(有或没有守护进程)来处理推送到队列的作业。这一切都很好,但如果我想在 Windows Azure Web 应用程序上执行此操作怎么办?在搜索了我发现的解决方案后:

  • Make a chron job to run "php artisan queue:listen" every minute (or every X minutes), I really dislike this solution and wanted to avoid it specially if the site gets more traffic;
  • Add a WebJob that runs "php artisan queue:listen" continuously (the problem here is I don't know how to write the script for the WebJob...);
  • 做一个 chron 作业,每分钟(或每 X 分钟)运行“php artisan queue:listen”,我真的不喜欢这个解决方案,并希望在网站获得更多流量时特别避免它;
  • 添加一个连续运行“php artisan queue:listen”的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.

我想请教各位帮忙,看看哪一个是正确的解决方案,如果有更好的解决方案,如果 WebJob 是最好的解决方案,我该如何为此编写脚本?提前致谢。

采纳答案by Justin Origin Broadband

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

简而言之,Supervisor 是 nohup(不挂断)的现代替代品,并附加了其他一些零碎的东西。简而言之,还有其他资源可以让任务在后台运行(守护进程),我用于基于 Windows 的项目(很少 tbh)的解决方案是 Forever,我通过以下方式发现:https: //stackoverflow.com/a/18226392 /5912664

C:\myprojectroot > forever -c php artisan queue:listen --queue=some_nice_queue --tries=3

How?

如何?

Install nodefor Windows, then with npminstall Forever

node为 Windows安装,然后npm安装Forever

C:\myprojectroot > npm install -g forever

If you're stuck for getting Node running on Windows, I recommend the Windows Package Manager, Chocolatey

如果你坚持让 Node 在 Windows 上运行,我推荐 Windows 包管理器, Chocolatey

https://chocolatey.org/packages?q=node

https://chocolatey.org/packages?q=node

Be sure to check for any logfiles that Forevercreates, as I had left one long enough to consume 30Gb of disk space!

一定要检查Forever创建的任何日志文件,因为我留下的日志文件已经足够消耗 30Gb 的磁盘空间了!

回答by Ernesto Lugo

For Azure you can make a new webjob to your web app, and upload a .cmd file including a command like this.

对于 Azure,您可以为您的 Web 应用程序创建一个新的 webjob,并上传一个 .cmd 文件,其中包含这样的命令。

php %HOME%\site\wwwroot\artisan queue:work --daemon

and defining that as a triguered and 0 * * * * * frequency cron.

并将其定义为一个triguered和0 * * * * *频率cron。

that way work for me.

这样对我有用。

best.

最好的事物。