Skip to content

Commit f729731

Browse files
pengzhoumlPeng Zhou
andauthored
MLE-21263: Remove PID for Logging redirection (#317)
Co-authored-by: Peng Zhou <[email protected]>
1 parent 93542e2 commit f729731

File tree

1 file changed

+4
-26
lines changed

1 file changed

+4
-26
lines changed

charts/templates/configmap-scripts.yaml

Lines changed: 4 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,9 @@ metadata:
1010
data:
1111
liveness-probe.sh: |
1212
#!/bin/bash
13-
pid=$(ps aux | grep "/bin/bash /usr/local/bin/start-marklogic.sh" | grep -v grep | awk '{print $2}')
1413
log () {
1514
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
16-
# Check to make sure pod doesn't terminate if PID value is empty for any reason
17-
if [ -n "$pid" ]; then
18-
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
19-
fi
15+
echo "${TIMESTAMP} $@" > /proc/1/fd/1
2016
}
2117
2218
# Check if ML service is running. Exit with 1 if it is other than running
@@ -118,15 +114,9 @@ data:
118114
MARKLOGIC_ADMIN_USERNAME="$(< /run/secrets/ml-secrets/username)"
119115
MARKLOGIC_ADMIN_PASSWORD="$(< /run/secrets/ml-secrets/password)"
120116
121-
pid=$(ps aux | grep "/bin/bash /usr/local/bin/start-marklogic.sh" | grep -v grep | awk '{print $2}')
122-
123117
log () {
124118
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
125-
# Check to make sure pod doesn't terminate if PID value is empty for any reason
126-
# If PID value is empty preStart hook logs are not recorded
127-
if [ -n "$pid" ]; then
128-
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
129-
fi
119+
echo "${TIMESTAMP} $@" > /proc/1/fd/1
130120
}
131121
132122
log "Info: [prestop] Prestop Hook Execution"
@@ -195,8 +185,6 @@ data:
195185
echo "IS_BOOTSTRAP_HOST false"
196186
fi
197187
198-
pid=$(ps aux | grep "/bin/bash /usr/local/bin/start-marklogic.sh" | grep -v grep | awk '{print $2}')
199-
200188
###############################################################
201189
# Logging utility
202190
###############################################################
@@ -215,13 +203,8 @@ data:
215203
216204
log () {
217205
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
218-
# Check to make sure pod doesn't terminate if PID value is empty for any reason
219-
# If PID value is empty postStart hook logs are not recorded
220206
message="${TIMESTAMP} [postStart] $@"
221-
if [ -n "$pid" ]; then
222-
echo $message > /proc/$pid/fd/1
223-
fi
224-
207+
echo $message > /proc/1/fd/1
225208
echo $message >> /tmp/script.log
226209
}
227210
@@ -889,13 +872,8 @@ data:
889872
#!/bin/bash
890873
log () {
891874
local TIMESTAMP=$(date +"%Y-%m-%d %T.%3N")
892-
# Check to make sure pod doesn't terminate if PID value is empty for any reason
893-
if [ -n "$pid" ]; then
894-
echo "${TIMESTAMP} $@" > /proc/$pid/fd/1
895-
fi
875+
echo "${TIMESTAMP} $@" > /proc/1/fd/1
896876
}
897-
898-
pid=$(ps aux | grep "/bin/bash /usr/local/bin/start-marklogic.sh" | grep -v grep | awk '{print $2}')
899877
900878
log "Info: [root-rootless-upgrade] Execution Start"
901879

0 commit comments

Comments
 (0)