Skip to content

Use exec inside of entry.sh to correctly propagate SIGTERM to Java #17

Description

@semik

Change description

I suggest slight change to entry.sh:

diff --git a/docker/opt/cscapi/entry.sh b/docker/opt/cscapi/entry.sh
index 60e5db1..fe69425 100755
--- a/docker/opt/cscapi/entry.sh
+++ b/docker/opt/cscapi/entry.sh
@@ -8,9 +8,9 @@ log "INFO" "Launching the CSC API"
 # Set debug options if required
 if [ x"${REMOTE_DEBUG}" != x ] && [ "${REMOTE_DEBUG}" != "false" ]
 then
-  java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar ./app.jar
+  exec java -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:5005 -jar ./app.jar
 else
-  java -jar ./app.jar --spring.config.location=optional:file:/opt/cscapi/application.yml
+  exec java -jar ./app.jar --spring.config.location=optional:file:/opt/cscapi/application.yml
 fi
 
 #exec "$@"

This asures that java run under PID=1 and thus receiving SIGTERM signal from Docker and correctly and faster shutdown. Without this change shutdown takes 10s, after change is shutdown within 1s.

Please read this info https://stackoverflow.com/questions/31836498/sigterm-not-received-by-java-process-using-docker-stop-and-the-official-java-i for detailed explanation if needed.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions