does railway support on("beforeExit")

The title is pretty much self explanatory, I have this in my code and I don't find the log "beforeExit".
No description
Solution:
it seems that if you run it with npm, npm will receive the sigterm instead of node because node process is a children of the npm process info: https://help.heroku.com/ROG3H81R/why-does-sigterm-handling-not-work-correctly-in-nodejs-with-npm...
Jump to solution
21 Replies
Percy
Percyβ€’3mo ago
Project ID: a3b76fbf-72bb-4131-9e22-b084af93e94a
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
a3b76fbf-72bb-4131-9e22-b084af93e94a
ThallesComH
ThallesComHβ€’3mo ago
you should probably use the sigterm event instead of beforeExit
process.on('SIGTERM', () => { console.log("exiting...") });
process.on('SIGTERM', () => { console.log("exiting...") });
also Railway force kills your container after a while if it takes way too long to exit, you can set the RAILWAY_DEPLOYMENT_DRAINING_SECONDS to how long you want to prevent that from happening
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
cool ! thanks
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
No description
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
SIGTERM is never logged And I don't see any changes in my database (should exist if my function "saveUsersProgress" launches after SIGTERM
ThallesComH
ThallesComHβ€’3mo ago
do you run your app with npm run <..>?
Solution
ThallesComH
ThallesComHβ€’3mo ago
it seems that if you run it with npm, npm will receive the sigterm instead of node because node process is a children of the npm process info: https://help.heroku.com/ROG3H81R/why-does-sigterm-handling-not-work-correctly-in-nodejs-with-npm
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
yes it stats with npm run
ThallesComH
ThallesComHβ€’3mo ago
try to start it with node directly then
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
what should i change then ?
No description
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
add a build command and then node index.js (its a ts project)
ThallesComH
ThallesComHβ€’3mo ago
go to your service settings, scroll down and you should find a custom start command place your start script command there service*
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
@ThallesComH Hey sorry for the delay it didn't work no logs when redeploying
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
No description
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
none of those
ThallesComH
ThallesComHβ€’3mo ago
hey, thats really weird i'll try to write a code to see whats happening, report back here soon
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
ty
Brody
Brodyβ€’3mo ago
what did you end up setting your start command to in the railway service settings? likely just an incorrect start command, since thalles is right, this is caused by you running your app through npm as npm does not pass down signals
Anthony πŸ¦…
Anthony πŸ¦…OPβ€’3mo ago
Just checked back, It seems like I didn't save the changes, did it now and it works ty so much guys
Brody
Brodyβ€’3mo ago
awsome!
Want results from more Discord servers?
Add your server