From 2b160fbbc2be917a47cf329db44ccaba95efdc1c Mon Sep 17 00:00:00 2001 From: ibuler Date: Thu, 15 Aug 2024 20:09:55 +0800 Subject: [PATCH] revert: entrypoint.sh --- entrypoint.sh | 30 ++++++++++++++++++++++-------- 1 file changed, 22 insertions(+), 8 deletions(-) diff --git a/entrypoint.sh b/entrypoint.sh index 2b0a87307..acd23b51c 100755 --- a/entrypoint.sh +++ b/entrypoint.sh @@ -1,12 +1,26 @@ #!/bin/bash -# -rm -f /opt/jumpserver/tmp/*.pid +# 不能删掉 cleanup 会产生僵尸进程 +function cleanup() +{ + local pids=`jobs -p` + if [[ "${pids}" != "" ]]; then + kill ${pids} >/dev/null 2>/dev/null + fi +} + +action="${1-start}" +service="${2-all}" -case "$1" in - start|init_db|upgrade_db) - set -- /opt/jumpserver/jms "$@" - ;; -esac +trap cleanup EXIT + +rm -f /opt/jumpserver/tmp/*.pid -exec "$@" +if [[ "$action" == "bash" || "$action" == "sh" ]];then + bash +elif [[ "$action" == "sleep" ]];then + echo "Sleep 365 days" + sleep 365d +else + python jms "${action}" "${service}" +fi