#Apps Handling Removing Deploys (or redeploys)

24 messages · Page 1 of 1 (latest)

strong monolith
#

hello! i have a java project hosted on Railway (id: d8c2d7d4-9cc2-4de3-a784-cb082a468bda), in which i have registered JVM shutdown hooks. essentially initialised but unstarted java threads that start when the virtual machine begins its shutdown sequence.

unfortunately, when i remove a deploy on Railway, or push a commit to GH, which pushes a redeploy, these shutdown hooks do not get fired. is there something i can configure to make this work?

many thanks

tough bearBOT
#

Project ID: d8c2d7d4-9cc2-4de3-a784-cb082a468bda

placid halo
#

Hello,

When an old deploy is being shut down we send sigterm and then wait 3 seconds, are your shut down hooks listening for sigterm specifically?

strong monolith
placid halo
#

perhaps there is something that is not passing the signals down to your app? for example, for node, npm will not pass the signals

strong monolith
placid halo
#

we dont stop java apps in any way different from any other application, we send the sigterm, wait 3 seconds, and kill the container

strong monolith
#

the last thing that's viewable in the deploy logs is the container stopping. would it log the container being killed?

wondering if my shutdownhooks perhaps are taking too long, so Railway just ends up killing the container

placid halo
#

its very possible they are taking longer than 3 seconds, and that can be increased with a RAILWAY_DEPLOYMENT_DRAINING_SECONDS variable

strong monolith
placid halo
#

I promise you we send sigterm, I can write a simple test program to prove this behaviour if you'd like? (it won't be in java though)

strong monolith
#

i do have a small hacky solution that sort of works. for context, this is a discord bot that i am hosting. i have a slash-command /exit that internally makes the java program run exit with code 0. that ends up triggering my Shutdown hooks on railway, and then marks the build as COMPLETED rather than REMOVED. Downside of this is that each time i push a commit, i need to manually run /exit to run my shutdown hooks. and then let railway redeploy.

is this (this being SIGTERM not being received) something that Railway could even take a look at? im happy to spin up a very basic java program to see if it's working as intended

placid halo
#

its not something we could take a look at because its an issue at the application level and not an issue at the platform level

strong monolith
placid halo
#

given the platform did send the sigterm, yes that would still be an application level issue

strong monolith
placid halo
#

all we are doing is running java -jar target/commissionsmanager-1.0-SNAPSHOT.jar

strong monolith
# placid halo all we are doing is running `java -jar target/commissionsmanager-1.0-SNAPSHOT.ja...

i see. how is the docker container stopped? does it just issue a docker stop command?

reason why i ask, is that this thread may be of some interest:

https://stackoverflow.com/questions/31836498/sigterm-not-received-by-java-process-using-docker-stop-and-the-official-java-i

placid halo
#

have you tried the suggestion in the first response?

strong monolith
# placid halo

cheers brody, i really appreciate your patience with me! was able to get things working as expected by prefixing with exec.

really loving railway the more and more i use it :)

placid halo
#

awsome, glad i could help in some way haha

#

!s