-
Notifications
You must be signed in to change notification settings - Fork 18
Server refuses to die in container #5
Comments
We listen for So is there any way to detect that app is inside a Docker container, so that we can listen for this event? Why not always listen for it?Because the terminal sends |
Could't we always listen for |
I think @RomainLanz has good idea. Could log some message like: Also it seems it turned out to be issue in |
…utting down message This commit will make Ignitor to always listen for SIGINT so server is killable in containers. adonisjs-community/create-adonis-ts-app#5
This commit will make Ignitor to always listen for SIGINT so server is killable in containers. adonisjs-community/create-adonis-ts-app#5
If the process is running from a terminal, display a message to the user telling that they can press CTRL+C again to force an immediate shutdown. Closes: adonisjs-community/create-adonis-ts-app#5
Opened adonisjs/core#2273 to try and fix this |
The problem might be that nodejs is not designed to run as PID 1 which leads to unexpected behaviour when running inside of Docker. For example, a Node.js process running as PID 1 will not respond to SIGINT (CTRL-C) and similar signals. I suggest you use a lightweight init system (like tini) to wrap you nodejs process. |
SIGINT
seems to be ignored by server. HTTP server exposes.kill()
and.close()
but default listener for SIGINT seems to be missingPackage version
Adonis packages
Node.js and npm version
NodeJS: 13.9.0
NPM: 6.13.7
Sample Code (to reproduce the issue)
When building container and setting start command as
CMD [ "node", "./build/server.js" ]
Container does not die gracefully with
SIGINT
sinceSIGINT
is sent to process, which just ignores itFix is to add
process.on('SIGINT')
yourself to some part of application,server.ts
for exampleWorkaround is to chop it into multiple pieces and adding
SIGINT
listenerBONUS (a sample repo to reproduce the issue)
https://gitlab.com/McSneaky/youtube-downloader
The text was updated successfully, but these errors were encountered: