You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I am using Bull in conjunction with NestJS for an API server. (It is working beautifully, I am very impressed with this project and its integration!)
I am, however, running into a problem with CLI commands. The CLI boots up a new instance of the server, runs a few seed commands (including the insertion of some Bull jobs), and then shuts down. The problem is, the Bull jobs start running immediately in the CLI runtime, and crash out when required services (notably the database) are turned off.
pause() and resume() don't work in this context; when I run queue.pause() upon CLI startup, the pause state is stored in Redis, so my API server pauses jobs — not ideal — and when I queue.resume() upon CLI shutdown, the same crashing thing happens.
I feel like the real solution here is to have a flag separate from isPaused perhaps called isSuspended; the "suspended" state would function the same as isPaused, but be defined in the runtime memory instead of in Redis.
Does this make any sense? Or is there already a way to handle this that I'm overlooking?
The text was updated successfully, but these errors were encountered:
(note that I have found one way around this, which is to add a delay of one minute to newly inserted jobs when the CLI environment is detected; I think this is kind of hacky, and anyway if the CLI command takes more than a minute, or a job is inserted on the live server while the CLI instance is running, I'm back to square one…)
I'm not familiar with NestJS, but this seems like more of a feature suggestion for the NestJS integration if anything.
In usage of Bull itself, a queue instance will only process jobs if it has a processor attached to it, so queues are basically in accept-jobs-only mode by default. See this example, where I add a job to the queue, but it doesn't start processing until I call queue.process():
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
I am using Bull in conjunction with NestJS for an API server. (It is working beautifully, I am very impressed with this project and its integration!)
I am, however, running into a problem with CLI commands. The CLI boots up a new instance of the server, runs a few seed commands (including the insertion of some Bull jobs), and then shuts down. The problem is, the Bull jobs start running immediately in the CLI runtime, and crash out when required services (notably the database) are turned off.
pause()
andresume()
don't work in this context; when I runqueue.pause()
upon CLI startup, the pause state is stored in Redis, so my API server pauses jobs — not ideal — and when Iqueue.resume()
upon CLI shutdown, the same crashing thing happens.I feel like the real solution here is to have a flag separate from
isPaused
perhaps calledisSuspended
; the "suspended" state would function the same as isPaused, but be defined in the runtime memory instead of in Redis.Does this make any sense? Or is there already a way to handle this that I'm overlooking?
The text was updated successfully, but these errors were encountered: