Skip to content
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

Question: about long and short processes #541

Open
gherciu opened this issue Jan 28, 2025 · 3 comments
Open

Question: about long and short processes #541

gherciu opened this issue Jan 28, 2025 · 3 comments

Comments

@gherciu
Copy link

gherciu commented Jan 28, 2025

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
Copy link
Author

gherciu commented Jan 28, 2025

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

@timgit
Copy link
Owner

timgit commented Jan 30, 2025

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

@gherciu
Copy link
Author

gherciu commented Jan 30, 2025

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants