Node app crashes on initial deploy only

5 months ago

I have a very simple Node app (vanilla JS with Fastify).

During initial deployment, it always hits SIGTERM and the container shuts down:

> my-app@1.0.1 start

> node index.js

my-app is listening on port 8080

Stopping Container

npm ERR! path /app

npm ERR! command failed

npm ERR! signal SIGTERM

npm ERR! command sh -c node index.js

npm ERR! A complete log of this run can be found in: /root/.npm/_logs/2024-12-03T19_54_05_039Z-debug-0.log

The 8080 port is passed in via Railway's PORT env var (as far as I know), and there shouldn't be any issues there?

Curiously, it always fails the first time, then works from there. Any clues?

Awaiting User Response

3 Replies

5 months ago

Hello,

Those logs you are looking at are for old deployments that have been replaced by a new deployment.

The app prints that error because its not being passed the sigterm signal by npm.

To avoid it, update your start command in the service settings to run the app with node directly instead of through npm.

Hope this helps!


Status changed to Awaiting User Response railway[bot] 5 months ago


5 months ago

Very interesting - thank you for the tip, I'll give it a try!


Status changed to Awaiting Railway Response railway[bot] 5 months ago


5 months ago

Let me know if you run into any troubles!


Status changed to Awaiting User Response railway[bot] 5 months ago


Node app crashes on initial deploy only - Railway Help Station