Laravel Task Scheduler across multiple servers without overlap

旧城冷巷雨未停 提交于 2019-12-23 19:16:17

问题


I am wondering if anyone has any experience with making the Laravel Task Scheduler work without overlapping across multiple servers.

To put it in context: I have 3 API servers behind a load balancer. I know the task scheduler allows for the withoutOverlap flag on a single server, but how could I use that same principal across all of my servers? I want only 1 server to run the scheduled tasks and have the other 2 servers not run them.

As far as I can tell, my options are:

Remove the crontab from 2 of the servers. I have my servers automated and would rather not remove the crontab job from any of the servers because that would complicate my automated builds.

Write a package that uses the DB to limit the tasks to only the first server that runs. I could do this, but am wondering if it has already been done (cannot find anything on google)

Any advice?


回答1:


One guy implement it already. check out this composer package https://packagist.org/packages/jdavidbakr/multi-server-event



来源:https://stackoverflow.com/questions/33485478/laravel-task-scheduler-across-multiple-servers-without-overlap

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!