Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gracefully handle SIGTERM by trapping the signal #422

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions dockerfiles/alpine/apim/docker-entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -65,9 +65,19 @@ test -d ${artifact_volume} && [[ "$(ls -A ${artifact_volume})" ]] && cp -RL ${ar
echo "Start WSO2 Carbon server" >&2
if [[ -z "${PROFILE_NAME}" ]]
then
# Trapping Kill Signals and killing the leaf process
trap 'echo kill signal received!; kill -TERM $(tr -d "\0" < ${WSO2_SERVER_HOME}/wso2carbon.pid); wait' TERM INT
# start the server with the provided startup arguments
sh ${WSO2_SERVER_HOME}/bin/api-manager.sh "$@"
${WSO2_SERVER_HOME}/bin/api-manager.sh "$@" &
# Waiting for the Subprocess to finish
PID=$!
wait $PID
else
# Trapping Kill Signals and killing the leaf process
trap 'echo kill signal received!; kill -TERM $(tr -d "\0" < ${WSO2_SERVER_HOME}/wso2carbon.pid); wait' TERM INT
# start the server with the specified profile and provided startup arguments
sh ${WSO2_SERVER_HOME}/bin/api-manager.sh -Dprofile=${PROFILE_NAME} "$@"
sh ${WSO2_SERVER_HOME}/bin/api-manager.sh -Dprofile=${PROFILE_NAME} "$@" &
# Waiting for the Subprocess to finish
PID=$!
wait $PID
fi