From 4c09ef752cd766d40f319b962c88c34da7d2070a Mon Sep 17 00:00:00 2001 From: Daniel Ceregatti Date: Thu, 12 Oct 2023 21:52:33 -0700 Subject: [PATCH] Switch from CMD to ENTRYPOINT, then use exec in both start.sh scripts, so process id 1 can be the process it needs to be, as this is what gets SIGTERM on docker compose down. We now get a .bashrc by default, so switch the logic to detecting the custom PS1 before putting it in .bashrc. Account for a directory that steamcmd expects. --- server/Dockerfile | 2 +- server/bin/dz | 11 +++++++++-- server/start.sh | 2 +- web/Dockerfile | 2 +- web/start.sh | 14 ++++++++++---- 5 files changed, 22 insertions(+), 9 deletions(-) diff --git a/server/Dockerfile b/server/Dockerfile index 8a54ead..81d310b 100644 --- a/server/Dockerfile +++ b/server/Dockerfile @@ -54,4 +54,4 @@ USER user WORKDIR /home/user # Run the server. -CMD ["start.sh"] +ENTRYPOINT ["start.sh"] diff --git a/server/bin/dz b/server/bin/dz index 170bbe9..34198fb 100755 --- a/server/bin/dz +++ b/server/bin/dz @@ -242,7 +242,7 @@ mergexml(){ # Start the server in the foreground start(){ # Ensure mpmissions has at least one map. If not, copy it from the local read-only volume that stores pristine mpmissons directories - if [ ! -d "${MPMISSIONS}/${MAP}" ] + if [ ! -d "${MPMISSIONS}/${MAP}" ] && [ -d "/mpmissions/${MAP}" ] then echo echo "Performing one-time copy of ${MAP} mpmissions..." @@ -253,7 +253,14 @@ start(){ if [[ ${DEVELOPMENT} = "1" ]] then echo "DEVELOPMENT mode, blocking. Unset DEVELOPMENT in the current environment to run the server." - tail -f /dev/null + trap ' + echo "Caught SIGTERM/SIGINT..." + exit 0 + ' SIGTERM SIGINT + while true + do + sleep 1 + done exit 0 fi # Do the report on exit. Set here so that it only happens once we're starting the server, and not for other actions. diff --git a/server/start.sh b/server/start.sh index d8749c0..7b83f9f 100755 --- a/server/start.sh +++ b/server/start.sh @@ -8,4 +8,4 @@ EOF # Start the server. # If the DEVELOPMENT environment variable is set to 1, the container will just block and not start the server. -dz start +exec dz start diff --git a/web/Dockerfile b/web/Dockerfile index 682fb0c..14d9bfa 100644 --- a/web/Dockerfile +++ b/web/Dockerfile @@ -81,4 +81,4 @@ USER user WORKDIR /home/user # Run the web server -CMD ["start.sh"] +ENTRYPOINT ["start.sh"] diff --git a/web/start.sh b/web/start.sh index 5df5610..4f9ac7d 100755 --- a/web/start.sh +++ b/web/start.sh @@ -1,15 +1,21 @@ #!/usr/bin/env bash # Set PS1 so we know we're in the container -if ! [ -f .bashrc ] +if ! echo .bashrc | grep -q "dz-web" then - echo "Creating .bashrc..." - cat > .bashrc <> .bashrc <