pg-boss icon indicating copy to clipboard operation
pg-boss copied to clipboard

Question: about long and short processes

Open gherciu opened this issue 11 months ago • 3 comments

I have a question about how to add jobs to a queue in a short living script.

So I have an application that creates the queues using the createQueue method and it also adds the .work method after that and handles the jobs, and here everything works.

Now in another Node Process/script/cron_job which is totally separated from the main app I'm trying to add , Only add jobs to the queues, not wait and handle any. And in that file I just use the createQueue method to start a queue and add jobs to it, I do not use the .work method to handle anything since I want the process node process to finish and not hang and wait for something.

Now unfortunately the process hangs and waits for something.

And from here my question is how to add jobs to a queue in a separate running file/process correctly and not wait for something, since now I guess pg boss once initialized just waits for something.

is it safe to close the short living process with process.exit? or what is the suggestion

gherciu avatar Jan 28 '25 15:01 gherciu

Or may it be in may case that I have a on stopped and error events, and these may hang the process? I'll try to remove and check

gherciu avatar Jan 28 '25 16:01 gherciu

createQueue() shouldn't cause a delay like that.

timgit avatar Jan 30 '25 01:01 timgit

I guess then is my listeners I have 2 listeners on the PGBoss instance like 'on stopped' and 'on error' I'll try to use a removeAllListeners and guess that will help

Thanks

gherciu avatar Jan 30 '25 07:01 gherciu