-
Notifications
You must be signed in to change notification settings - Fork 132
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
About running the job only one time on restart #111
Comments
there may be cases where a delay is acceptable. |
I end up doing it in a weird way a long time ago. There are probably better solutions (if I recall correctly, Jesque works by adding the waitTime to each key until it's bigger than the current time - so another solution to this problem is to simply set the time to now + waitTime instead of adding), but I just created a method that is called when the application is started, and uses a lua script to reset all scores. Class:
The script:
Putting it here in case it helps someone. |
重置脚本 需要判断是否是循环任务 是否score小于now
|
If I stop my application and restart it after some time (using the same queue names), it will execute the jobs as many times as it should have run if my application didn't stop. Is there a way to make it execute only one time?
From what I got in the lua script, it adds the frequency in the job score when popping it, so I guess I could achieve what I want by setting all the existing job scores as the current time when the application starts. But I wanted to know if there is a solution for that already, or some other idea, because it looks hackish.
The delayed job, if I understand correctly, don't fit well since I need to re-add the job after it runs, and I guess I could lose a job if my application stopped in the middle of the process.
The text was updated successfully, but these errors were encountered: