Skip to content

Commit 6337060

Browse files
committed
put stop server marker file in /tmp, put stop server out file in ../servers/<server-name>/logs
1 parent dba2271 commit 6337060

File tree

2 files changed

+17
-13
lines changed

2 files changed

+17
-13
lines changed

operator/src/main/resources/scripts/startServer.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -111,7 +111,7 @@ function waitForShutdownMarker() {
111111
#
112112
trace "Wait indefinitely so that the Kubernetes pod does not exit and try to restart"
113113
while true; do
114-
if [ -e ${DOMAIN_HOME}/doShutdown ] ; then
114+
if [ -e /tmp/doShutdown ] ; then
115115
exit 0
116116
fi
117117
sleep 3

operator/src/main/resources/scripts/stopServer.sh

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
1313
source ${SCRIPTPATH}/traceUtils.sh
1414
[ $? -ne 0 ] && echo "Error: missing file ${SCRIPTPATH}/traceUtils.sh" && exit 1
1515

16-
trace "Stop server ${SERVER_NAME}" &>> /weblogic-operator/stopserver.out
16+
trace "Stop server ${SERVER_NAME}" &>> ${SERVER_OUT_FILE}
1717

1818
checkEnv SERVER_NAME || exit 1
1919

@@ -28,27 +28,31 @@ function check_for_shutdown() {
2828
state=`${SCRIPTPATH}/readState.sh`
2929
exit_status=$?
3030
if [ $exit_status -ne 0 ]; then
31-
trace "Node manager not running or server instance not found; assuming shutdown" &>> /weblogic-operator/stopserver.out
31+
trace "Node manager not running or server instance not found; assuming shutdown" &>> ${SERVER_OUT_FILE}
3232
return 0
3333
fi
3434

3535
if [ "$state" = "SHUTDOWN" ]; then
36-
trace "Server is shutdown" &>> /weblogic-operator/stopserver.out
36+
trace "Server is shutdown" &>> ${SERVER_OUT_FILE}
3737
return 0
3838
fi
3939

4040
if [[ "$state" =~ ^FAILED ]]; then
41-
trace "Server in failed state" &>> /weblogic-operator/stopserver.out
41+
trace "Server in failed state" &>> ${SERVER_OUT_FILE}
4242
return 0
4343
fi
4444

45-
trace "Server is currently in state $state" &>> /weblogic-operator/stopserver.out
45+
trace "Server is currently in state $state" &>> ${SERVER_OUT_FILE}
4646
return 1
4747
}
4848

49+
# setup ".out" location for a WL server
50+
serverLogHome="${LOG_HOME:-${DOMAIN_HOME}/servers/${SERVER_NAME}/logs}"
51+
SERVER_OUT_FILE="${serverLogHome}/stop-${SERVER_NAME}.out"
52+
4953
# Check if the server is already shutdown
5054
check_for_shutdown
51-
[ $? -eq 0 ] && trace "Server already shutdown or failed" &>> /weblogic-operator/stopserver.out && exit 0
55+
[ $? -eq 0 ] && trace "Server already shutdown or failed" &>> ${SERVER_OUT_FILE} && exit 0
5256

5357
# Otherwise, connect to the node manager and stop the server instance
5458
[ ! -f "${SCRIPTPATH}/wlst.sh" ] && trace "Error: missing file '${SCRIPTPATH}/wlst.sh'." && exit 1
@@ -60,23 +64,23 @@ export SHUTDOWN_TIMEOUT_ARG=${SHUTDOWN_TIMEOUT:-30}
6064
export SHUTDOWN_IGNORE_SESSIONS_ARG=${SHUTDOWN_IGNORE_SESSIONS:-false}
6165
export SHUTDOWN_TYPE_ARG=${SHUTDOWN_TYPE:-Graceful}
6266

63-
trace "Before stop-server.py [${SERVER_NAME}] ${SCRIPTDIR}" &>> /weblogic-operator/stopserver.out
64-
${SCRIPTPATH}/wlst.sh /weblogic-operator/scripts/stop-server.py &>> /weblogic-operator/stopserver.out
65-
trace "After stop-server.py" &>> /weblogic-operator/stopserver.out
67+
trace "Before stop-server.py [${SERVER_NAME}] ${SCRIPTDIR}" &>> ${SERVER_OUT_FILE}
68+
${SCRIPTPATH}/wlst.sh /weblogic-operator/scripts/stop-server.py &>> ${SERVER_OUT_FILE}
69+
trace "After stop-server.py" &>> ${SERVER_OUT_FILE}
6670

6771
# at this point node manager should have terminated the server
6872
# but let's try looking for the server process and
6973
# kill the server if the process still exists,
7074
# just in case we failed to stop it via wlst
7175
pid=$(jps -v | grep " -Dweblogic.Name=${SERVER_NAME} " | awk '{print $1}')
7276
if [ ! -z $pid ]; then
73-
echo "Killing the server process $pid" &>> /weblogic-operator/stopserver.out
77+
echo "Killing the server process $pid" &>> ${SERVER_OUT_FILE}
7478
kill -15 $pid
7579
fi
7680

77-
touch ${DOMAIN_HOME}/doShutdown
81+
touch /tmp/doShutdown
7882
if [ -f /weblogic-operator/pid ]; then
7983
kill -2 $(</weblogic-operator/pid)
8084
fi
8185

82-
trace "Exit script" &>> /weblogic-operator/stopserver.out
86+
trace "Exit script" &>> ${SERVER_OUT_FILE}

0 commit comments

Comments
 (0)