Skip to content

Commit bb685fd

Browse files
committed
Backport tail sooner enhancement
1 parent 4ced09a commit bb685fd

File tree

2 files changed

+52
-20
lines changed

2 files changed

+52
-20
lines changed

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

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,17 @@ function startWLS() {
6464

6565
traceTiming "POD '${SERVICE_NAME}' MD5 END"
6666

67+
#
68+
# We "tail" the future WL Server .out file to stdout in background _before_ starting
69+
# the WLS Server because we use WLST 'nmStart()' to start the server and nmStart doesn't return
70+
# control until WLS reaches the RUNNING state.
71+
#
72+
73+
if [ "${SERVER_OUT_IN_POD_LOG}" == 'true' ] ; then
74+
trace "Showing the server out file from ${SERVER_OUT_FILE}"
75+
${SCRIPTPATH}/tailLog.sh ${SERVER_OUT_FILE} ${SERVER_PID_FILE} &
76+
fi
77+
6778
#
6879
# Start WL Server
6980
#
@@ -76,6 +87,12 @@ function startWLS() {
7687
${SCRIPTPATH}/wlst.sh $SCRIPTPATH/start-server.py
7788

7889
traceTiming "POD '${SERVICE_NAME}' WLS STARTED"
90+
91+
FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR=${FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR:-true}
92+
SERVER_OUT_MONITOR_INTERVAL=${SERVER_OUT_MONITOR_INTERVAL:-3}
93+
if [ ${FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR} == 'true' ] ; then
94+
${SCRIPTPATH}/monitorLog.sh ${SERVER_OUT_FILE} ${SERVER_OUT_MONITOR_INTERVAL} &
95+
fi
7996
}
8097

8198
function mockWLS() {
@@ -89,22 +106,6 @@ function mockWLS() {
89106
echo "RUNNING:Y:N" > $STATEFILE
90107
}
91108

92-
function waitUntilShutdown() {
93-
#
94-
# Wait forever. Kubernetes will monitor this pod via liveness and readyness probes.
95-
#
96-
if [ "${SERVER_OUT_IN_POD_LOG}" == 'true' ] ; then
97-
trace "Showing the server out file from ${SERVER_OUT_FILE}"
98-
${SCRIPTPATH}/tailLog.sh ${SERVER_OUT_FILE} ${SERVER_PID_FILE} &
99-
fi
100-
FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR=${FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR:-true}
101-
SERVER_OUT_MONITOR_INTERVAL=${SERVER_OUT_MONITOR_INTERVAL:-3}
102-
if [ ${FAIL_BOOT_ON_SITUATIONAL_CONFIG_ERROR} == 'true' ] ; then
103-
${SCRIPTPATH}/monitorLog.sh ${SERVER_OUT_FILE} ${SERVER_OUT_MONITOR_INTERVAL} &
104-
fi
105-
waitForShutdownMarker
106-
}
107-
108109
# Define helper fn to copy sit cfg xml files from one dir to another
109110
# $src_dir files are assumed to start with $fil_prefix and end with .xml
110111
# Copied $tgt_dir files are stripped of their $fil_prefix
@@ -247,12 +248,18 @@ copySitCfg /weblogic-operator/introspector ${DOMAIN_HOME}/optconfig/jms
247248
copySitCfg /weblogic-operator/introspector ${DOMAIN_HOME}/optconfig/jdbc 'Sit-Cfg-JDBC--'
248249
copySitCfg /weblogic-operator/introspector ${DOMAIN_HOME}/optconfig/diagnostics 'Sit-Cfg-WLDF--'
249250

250-
251+
#
252+
# Start WLS
253+
#
251254

252255
if [ "${MOCK_WLS}" == 'true' ]; then
253256
mockWLS
254-
waitForShutdownMarker
255257
else
256258
startWLS
257-
waitUntilShutdown
258259
fi
260+
261+
#
262+
# Wait forever. Kubernetes will monitor this pod via liveness and readyness probes.
263+
#
264+
265+
waitForShutdownMarker

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

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,29 @@
1010
#
1111

1212
echo $$ > $2
13-
tail -F -n +0 $1
13+
14+
while true ; do
15+
if [ -f $1 ]; then
16+
tail -F -n +0 $1 || sleep 10
17+
fi
18+
sleep 0.1
19+
done
20+
21+
#
22+
# Work around note:
23+
#
24+
# The forever loop and '[ -f $1 ]' check above work around an
25+
# unexpected behavior from 'tail -F'. The '-F' expected
26+
# behavior is meant to handle 'rolling' files by both:
27+
#
28+
# A- Waiting until the file appears instead of exiting
29+
# with an error code.
30+
#
31+
# B- Once the file is found, gracefully handling the file
32+
# getting deleted or moved (by pausing while the file
33+
# is gone, and starting up again once a new file with
34+
# the same name appears in its place).
35+
#
36+
# But 'A' is not working on WL pods and thus the work around.
37+
# (Strangely and thankfully 'B' works fine.)
38+
#

0 commit comments

Comments
 (0)