问题
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