Scheduler跨多个服务器无重叠

Scheduler跨多个服务器无重叠

本文介绍了Laravel Task Scheduler跨多个服务器无重叠的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否有人在使Laravel Task Scheduler正常工作而不会在多个服务器上重叠的情况下有任何经验.

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

将其放在上下文中:我在负载均衡器后面有3个API服务器.我知道任务计划程序允许在单个服务器上使用noOverlap标志,但是如何在所有服务器上使用相同的主体?我只希望一台服务器运行计划的任务,而让其他两台服务器不运行它们.

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:

从2台服务器中删除crontab.我将服务器自动化,而不希望从任何一台服务器中删除crontab作业,因为这会使我的自动化构建复杂化.

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.

编写一个使用数据库将程序包限制为仅运行第一台服务器的程序包.我可以这样做,但想知道它是否已经完成(在Google上找不到任何内容)

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)

有什么建议吗?

推荐答案

一个人已经实现了它.签出这个作曲家包 https://packagist.org/packages/jdavidbakr/multi-server-event

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

这篇关于Laravel Task Scheduler跨多个服务器无重叠的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-28 07:05