dbsg
V2EX  ›  问与答

请教一下 egg 定时任务 worker 类型的问题

  •  
  •   dbsg · Apr 12, 2018 · 2861 views
    This topic created in 2986 days ago, the information mentioned may be changed or developed.

    我在定时任务里面设置 type: 'worker',官方解释是每台机器上只有一个 worker 会执行这个定时任务,每次执行定时任务的 worker 的选择是随机的。 我们的线上代码是运行在两台机器上的,这样的话是不是会发两次啊,请教下有什么办法能指定某个机器吗,就是不管几台机器,只有某一个机器才会发送。

    2 replies    2018-05-18 08:27:15 +08:00
    dbsg
        1
    dbsg  
    OP
       Apr 12, 2018
    我这边准备通过判断一下 ip 地址然后确认是否执行任务。
    atian25
        2
    atian25  
       May 18, 2018
    集群情况下,一般是要结合消息中间件,自定义一个 schedule type,官方文档有写
    About   ·   Help   ·   Advertise   ·   Blog   ·   API   ·   FAQ   ·   Solana   ·   1541 Online   Highest 6679   ·     Select Language
    创意工作者们的社区
    World is powered by solitude
    VERSION: 3.9.8.5 · 27ms · UTC 16:44 · PVG 00:44 · LAX 09:44 · JFK 12:44
    ♥ Do have faith in what you're doing.