Skip to content

App won't start in engine unix when using node-postgres #2590

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

Closed
janliska opened this issue Jul 30, 2021 · 4 comments
Closed

App won't start in engine unix when using node-postgres #2590

janliska opened this issue Jul 30, 2021 · 4 comments

Comments

@janliska
Copy link

Hi guys,

I'm having issues starting application when using nginx unit.
Container starts but it ends in loop of /usr/local/bin/docker-entrypoint.sh: Waiting for control socket to be removed... and it never finishes.
When I remove the postgres client all works well. I've tried to close the client connection on sigterm but with no luck.

Did anybody meet the same issue?

I've prepared simple demo app to reproduce the issue: https://github.com/janliska/pgsql-nginx-unit-issue

@brianc
Copy link
Owner

brianc commented Aug 3, 2021

looks like your app (in your example repo at least) is establishing a single postgres connection & never closing it.

you might want to try passing allowExitOnIdle to the pool:

const pool = new pg.Pool({ allowExitOnIdle: true })

or set a very short idleTimeoutMillis on the pool & use a connection pool for this. That way connections will be closed gracefully if they're not in use, allowing for a "clean" exit.

@janliska
Copy link
Author

janliska commented Aug 4, 2021

I've tried to close the client connection on sigterm (actually not only sigterm, also signint, exit and bunch of others), but it didn't help. It is not in the repo, but I tried something like process.on('SIGTERM', () => client.close());.

But I'll try the pool, thanks for tip :-)

brianc added a commit to brianc/node-postgres-docs that referenced this issue Sep 2, 2021
@brianc
Copy link
Owner

brianc commented Sep 2, 2021

brianc added a commit to brianc/node-postgres-docs that referenced this issue Sep 2, 2021
@brianc
Copy link
Owner

brianc commented Sep 2, 2021

closing unless I hear something else - @janliska hope you got everything worked out on your end!

@brianc brianc closed this as completed Sep 2, 2021
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