Skip to content
This repository has been archived by the owner on Oct 7, 2024. It is now read-only.

Commit

Permalink
Fix improper shutdown
Browse files Browse the repository at this point in the history
Run strapi in the background so we can catch signals and properly shutdown strapi.
Docker stop sends a SIGTERM which is ignored by strapi and causes Docker to kill the container (exit 137). This catches the SIGTERM and sends a SIGINT (CTRL-C) to strapi.
We cannot use STOPSIGNAL in the Dockerfile as SIGINT is a signal that will not be passed to PID 1 (which is the wrapper-script).
  • Loading branch information
msgeissler authored Mar 3, 2018
1 parent 487f5fd commit b0b96ad
Showing 1 changed file with 12 additions and 1 deletion.
13 changes: 12 additions & 1 deletion strapi.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,14 @@
#!/bin/sh
set -ea

_stopStrapi() {
echo "Stopping strapi"
kill -SIGINT "$strapiPID"
wait "$strapiPID"
}

trap _stopStrapi SIGTERM SIGINT

cd /usr/src/api

APP_NAME=${APP_NAME:-strapi-app}
Expand All @@ -15,4 +23,7 @@ then
fi

cd $APP_NAME
strapi start
strapi start &

strapiPID=$!
wait "$strapiPID"

0 comments on commit b0b96ad

Please sign in to comment.