does railway support on("beforeExit")
anthonyissa
HOBBYOP

2 years ago

The title is pretty much self explanatory, I have this in my code and I don't find the log "beforeExit".

31 Replies

anthonyissa
HOBBYOP

2 years ago

a3b76fbf-72bb-4131-9e22-b084af93e94a


2 years ago

you should probably use the sigterm event instead of beforeExit

process.on('SIGTERM', () => { console.log("exiting...") });

2 years ago

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


anthonyissa
HOBBYOP

2 years ago

cool ! thanks


anthonyissa
HOBBYOP

2 years ago

1277345298028560400


anthonyissa
HOBBYOP

2 years ago

SIGTERM is never logged


anthonyissa
HOBBYOP

2 years ago

And I don't see any changes in my database (should exist if my function "saveUsersProgress" launches after SIGTERM


2 years ago

do you run your app with npm run <..>?


2 years 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:


anthonyissa
HOBBYOP

2 years ago

yes it stats with npm run


2 years ago

try to start it with node directly then


anthonyissa
HOBBYOP

2 years ago

what should i change then ?

1277352304701342000


anthonyissa
HOBBYOP

2 years ago

add a build command and then node index.js


anthonyissa
HOBBYOP

2 years ago

(its a ts project)


2 years ago

go to your service settings, scroll down and you should find a custom start command
place your start script command there


2 years ago

service*


anthonyissa
HOBBYOP

2 years ago

Hey @ThallesComH sorry for the delay


anthonyissa
HOBBYOP

2 years ago

it didn't work


anthonyissa
HOBBYOP

2 years ago

i tried looking for those logs, but nothing

1279026200777330700


anthonyissa
HOBBYOP

2 years ago

@ThallesComH Hey sorry for the delay


anthonyissa
HOBBYOP

2 years ago

it didn't work


anthonyissa
HOBBYOP

2 years ago

no logs when redeploying


anthonyissa
HOBBYOP

2 years ago

1280086608111997000


anthonyissa
HOBBYOP

2 years ago

none of those


2 years ago

hey, thats really weird
i'll try to write a code to see whats happening, report back here soon


anthonyissa
HOBBYOP

2 years ago

ty


2 years ago

what did you end up setting your start command to in the railway service settings?


2 years ago

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


anthonyissa
HOBBYOP

2 years ago

Just checked back, It seems like I didn't save the changes, did it now and it works


anthonyissa
HOBBYOP

2 years ago

ty so much guys


2 years ago

awsome!


Loading...