Skip to content

Commit 82e67ec

Browse files
committed
move server log monitoring to a new script monitorLog.sh
1 parent fbc43f1 commit 82e67ec

File tree

4 files changed

+50
-17
lines changed

4 files changed

+50
-17
lines changed
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
#!/bin/bash
2+
3+
# Copyright 2019, Oracle Corporation and/or its affiliates. All rights reserved.
4+
# Licensed under the Universal Permissive License v 1.0 as shown at
5+
# http://oss.oracle.com/licenses/upl.
6+
7+
#
8+
# This script is used to monitor the server log until the server is
9+
# started successfully.
10+
# It is separate from startServer.sh so that it is easier to quickly
11+
# kill the process running this script.
12+
#
13+
14+
echo $$ > /tmp/monitorLog-pid
15+
16+
SCRIPTPATH="$( cd "$(dirname "$0")" > /dev/null 2>&1 ; pwd -P )"
17+
source ${SCRIPTPATH}/traceUtils.sh
18+
19+
trace "Monitoring server log file $1 with sleep interval of $2 seconds"
20+
21+
while true; do
22+
if grep -q "BEA-141335" $1 ; then
23+
msg=("WebLogic server failed to start due to missing or invalid"
24+
"situational configuration files, which may be due to invalid"
25+
"configOverride templates (these are specified via the"
26+
"configOverride attribute in the Domain custom resource)."
27+
"For details, please search your pod log or"
28+
"${SERVER_OUT_FILE} for the keyword 'situational'."
29+
)
30+
trace "${msg[*]}"
31+
exit 0
32+
fi
33+
if grep -q "BEA-000360" $1 ; then
34+
trace "WebLogic Server started successfully. Script exiting."
35+
exit 0
36+
fi
37+
sleep $2
38+
done
39+

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

Lines changed: 7 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,12 @@ function waitUntilShutdown() {
102102
trace "Showing the server out file from ${SERVER_OUT_FILE}"
103103
${SCRIPTPATH}/tailLog.sh ${SERVER_OUT_FILE} &
104104
fi
105+
FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR=${FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR:-true}
106+
SERVER_OUT_MONITOR_INTERVAL=${SERVER_OUT_MONITOR_INTERVAL:-30}
107+
if [ ${FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR} == 'true' ] ; then
108+
trace "Monitor server out file ${SERVER_OUT_FILE} for certain known errors"
109+
${SCRIPTPATH}/monitorLog.sh ${SERVER_OUT_FILE} ${SERVER_OUT_MONITOR_INTERVAL} &
110+
fi
105111
waitForShutdownMarker
106112
}
107113

@@ -110,19 +116,7 @@ function waitForShutdownMarker() {
110116
# Wait forever. Kubernetes will monitor this pod via liveness and readyness probes.
111117
#
112118
trace "Wait indefinitely so that the Kubernetes pod does not exit and try to restart"
113-
logged=false
114119
while true; do
115-
if [ "$logged" != 'true' ] && grep -q "BEA-141335" ${SERVER_OUT_FILE} ; then
116-
msg=("WebLogic server failed to start due to missing or invalid"
117-
"situational configuration files, which may be due to invalid"
118-
"configOverride templates (these are specified via the"
119-
"configOverride attribute in the Domain custom resource)."
120-
"For details, please search your pod log or"
121-
"${SERVER_OUT_FILE} for the keyword 'situational'."
122-
)
123-
trace "${msg[*]}"
124-
logged=true
125-
fi
126120
if [ -e /weblogic-operator/doShutdown ] ; then
127121
exit 0
128122
fi
@@ -150,8 +144,7 @@ function copySitCfg() {
150144
for local_fname in ${src_dir}/${fil_prefix}*.xml ; do
151145
copyIfChanged $local_fname $tgt_dir/`basename ${local_fname/${fil_prefix}//}`
152146
trace "Printing contents of situational configuration file $local_fname:"
153-
file_content=`cat $local_fname`
154-
echo "$file_content"
147+
echo `cat $local_fname`
155148
done
156149
fi
157150

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,5 +10,5 @@
1010
# running this script.
1111
#
1212

13-
echo $$ > /weblogic-operator/pid
14-
tail -F -n +0 $1
13+
echo $$ > /tmp/tailLog-pid
14+
tail -F -n +0 $1

operator/src/test/java/oracle/kubernetes/operator/helpers/ConfigMapHelperTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,8 @@ public class ConfigMapHelperTest {
6969
"traceUtils.py",
7070
"traceUtils.sh",
7171
"wlst.sh",
72-
"tailLog.sh"
72+
"tailLog.sh",
73+
"monitorLog.sh"
7374
};
7475

7576
private static final String introspectResult =

0 commit comments

Comments
 (0)