scheduled jobs randomly stop working
Hello! I have three different scheduled jobs at different intervals.
1 minute
10 minutes
2 minutes
They will run the first few times just fine. However, afterwards they just stop running entirely. I have to reboot sapphire completely for them to restart.
For context, this is using the latest none-alpha versions for scheduled tasks and the sapphire framework + it's dependencies
19 Replies
Depending on whether you use the bullmq or Amazon sqs method you're best off asking them because the sapphire plugin is only a very tiny wrapper around either services. The sapphire plugin does basically nothing but call those services.
Gotcha, thank you. Yes, it's bullmq
Could you tell me what methods we are calling in that library @Favna
GitHub
plugins/ScheduledTaskRedisStrategy.ts at main · sapphiredev/plugins
Plugins for the Sapphire Framework. Contribute to sapphiredev/plugins development by creating an account on GitHub.
Thank you. Looking at the
bullmq
issues it appears this is commonoh :\
sorry to hear that
we also tried different libs but we cant find anything that can be a good replacement
GitHub
Jobs stuck in delayed state indefinitely · Issue #1656 · taskforces...
I have a queue with mostly delayed jobs which get stuck in delayed state indefinitely. Restarting the worker solves the issue temporarily but it re-occurs on a regular basis. I was trying to replic...
interesting last message there
suppose you can try that
I am giving it a whirl now 🤞
The weird thing is that the jobs don't get stuck immediately
it is after a random period of time
No dice.
Im facing this issue aswell. deleting all tasks and registering them again works fine for me usually
Could you clarify what you did?
I had to resort to using
pm2
with a cron restart pattern for the momentGet all the tasks using
container.client.tasks.list
then loop through them and call tasks.delete on each task. Then just restart your bot and sapphire should register your tasks againWe could expedite this process by making
container.tasks.reregister
and container.tasks.reregisterAll
I suppose
Err the first one would be on a specific task I think. I don't remember how the structure is from the top of my headsorry to bug you, but do you have example code?
it does seem this came up after the upgrade to
bullmq
v3Something like this should hopefully work:
You can probably just eval that code and restart your bot it will register the tasks again
Hmm, what runs this code?
Just any other command that gets called?
You can just create a temp command to run it or just eval it if you have an eval command
Ah okay I see. The pm2 solution automates this problem so I'll probably keep using that until there's something better
It happens when you change the
JobName
I have faced this issue before, posted in #old-sapphire-support but can't find at the moment hah, but that's the reason I think that it happenedHmm what do you mean by that specifically?