Node Container doesn't handle SIGTERM
cryato
FREEOP

a year 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%5Fsignals%5Ffail

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

Pinned Solution

a year ago

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

Actually just PR'd that into the docs!

4 Replies

Railway
BOT

a year 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!


a year 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 11 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

a year 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.

a year ago

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

Actually just PR'd that into the docs!


Status changed to Solved brody 11 months ago


Welcome!

Sign in to your Railway account to join the conversation.

Loading...