Laravel:运行队列:在Windows Azure Web App上持续监听

Laravel:运行队列:在Windows Azure Web App上持续监听

问题描述:

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:

  • 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...);

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.

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

  • 每分钟(或每X分钟)制作一个chron作业来运行“php artisan queue:listen”,我真的不喜欢 这个解决方案,并希望特别避免它,如果该网站获得更多的流量; li>
  • 添加一个运行“php artisan queue:listen”的WebJob(这里的问题是我不知道怎么写 WebJob的脚本......); li> ul>

    我想请大家帮忙知道哪些是正确的解决方案,如果有的话 更好的一个,如果WebJob是最好的,我该如何为此编写脚本? 提前致谢。 p> div>

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

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

How?

Install node for Windows, then with npm install Forever

C:\myprojectroot > npm install -g forever

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

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

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

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

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

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

that way work for me.

best.