Hi everyone, I am from Thailand
I start using webman with kuberbetes. it will run on multiple server (pods) at the same time
I then have cron task setup (workerman/crontab) like this
new Crontab('0 * * * * *', function(){
\Webman\RedisQueue\Redis::send('SendCartRemiderAfter1Hour', []);
});
how to control or make sure it run only on one pod?
Hello leekung.
The following is my plan.
Add a file mark the server which crontab needs to be run. Code similar
Remember file
config/crontab.lock
do not push to git (addconfig/crontab.lock
to.gitignore
).File
config/crontab.lock
only exists on the server which running crontab.Thanks, I have got the idea with lock file but it is redis lock key instead.
the Crontab is left as it is with no change
I will change the consumer like this (borrow from Laravel onOneServer())