I am using the bull queue to process jobs.
Let's say a job is running with a status of active
when I restart my dev server. When the worker script starts up again, the process is still set to active
in the queue, so bull decides to start up the worker process again.
This become disruptive very quickly, as the script is often restarting during development, so many processes end up running and making a mess of things. All I want is bull to NOT restart these jobs when the server starts.
Things I've tried:
- setting
attempts: 1
when creating a job (also tried 0) https://github.com/OptimalBits/bull/blob/HEAD/REFERENCE.md#queueadd - using queue.clean() (https://github.com/OptimalBits/bull/blob/HEAD/REFERENCE.md#queueclean)
- Writing a script to remove active jobs (throws Error: Missing lock for job xx failed):
let active_jobs = await queue.getJobs(['active']);
active_jobs.forEach(async (active_job) => {
await active_job.discard()
await active_job.moveToFailed(new Error("Auto-killed during dev server restart"))
})
None of this works. Anyone have a solution to achieve this?