nginx / unit

NGINX Unit - universal web app server - a lightweight and versatile open source server that simplifies the application stack by natively executing application code across eight different programming language runtimes.
https://unit.nginx.org
Apache License 2.0
5.33k stars 323 forks source link

Node.js: nginx unit does not start with postgres #570

Open janliska opened 3 years ago

janliska commented 3 years ago

Hi guys,

I'm having issues starting application when using postgres. 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

tippexs commented 2 years ago

I will look into this. Sorry for the long delay. It is prob because you are setting up another listener in js as well.

  app.listen(8100, '0.0.0.0', async (err) => {
    console.log('listening...', err);
  });

I saw similiar issues running NGINX Unit in none daemonized mode (like in docker). Will send you a PR by the end of today.

tippexs commented 2 years ago

I was able to reproduce it. It is not really related to node but more to the way we are handling the TERM signal. Thanks for bringing that to our attention. Will let you know once fixed.

tippexs commented 1 year ago

The temp. fix is available and you are happy to test it. The official docker images will be updated accordingly.

https://gist.github.com/tippexs/125658d0c90b03f8fc5deac19a6322eb

Please clone the gist and replace the docker-entrypoint.sh script with this one. Let me know if this is working.