Node Container doesn't handle SIGTERM
cryato
FREEOP

2 months ago

In node.js project there are event handlers, but in railway deployment change, I see the log "sending signal SIGTERM to container", but don't see logs of index.js getting that signal.

The Dockerfile uses ENTRYPOINT with JSON-style params.

I have tested popular advice I found:

  • Using ENTRYPOINT or CMD.

  • using dumb-init

  • using tini

  • using init: true in docker-compose

But I still cannot make node.js hear those signals

I've made example project without any logic except signal handlers and regular "Still alive" log:

https://github.com/cryato/railway_signals_fail

Still alive. Initial launch (UTC): 2025-09-25T13:32:36.972Z

sending signal SIGTERM to container

Stopping Container

And am using Variable

RAILWAY_DEPLOYMENT_DRAINING_SECONDS=60

What am I missing in such configuration to let index.js hear the signals?

Solved$40 Bounty

4 Replies

Railway
BOT

2 months ago

Hey there! We've found the following might help you get unblocked faster:

If you find the answer from one of these, please let us know by solving the thread!


brody
EMPLOYEE

2 months ago

Hello,

You are running your application via npm, but npm is not passing SIGTERM correctly to your application. This is a widely known issue that happens everywhere, not just on Railway.


Status changed to Awaiting User Response Railway 2 months ago


brody

Hello,You are running your application via npm, but npm is not passing SIGTERM correctly to your application. This is a widely known issue that happens everywhere, not just on Railway.

cryato
FREEOP

2 months ago

Thank you — it used npm because it didn't see Dockerfile.

I was actually using docker-compose.yml file (learned now, that it is not supported) and "Dockerfile.bot". As I renamed "Dockerfile.bot" to "Dockerfile", it started working


brody

Hello,You are running your application via npm, but npm is not passing SIGTERM correctly to your application. This is a widely known issue that happens everywhere, not just on Railway.

noahd
EMPLOYEE

2 months ago

https://github.com/railwayapp/docs/pull/879

Actually just PR'd that into the docs!


Status changed to Solved brody 2 months ago


Loading...