Skip to content

Commit 8ee12c5

Browse files
committed
fix log checker doesnt work for stderr
1 parent 1226c55 commit 8ee12c5

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed

entrypoint.sh

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ echo "entrypoint.sh: activate log checker!"
8484

8585
pipe=$(mktemp -u)
8686
mkfifo $pipe
87-
$STARTCMD $ARGS > $pipe &
87+
$STARTCMD $ARGS > $pipe 2>&1 &
8888
SRV_PID=$!
8989
SHELL_PID=$$
9090

@@ -94,12 +94,15 @@ SteamSockets API: Error"
9494
(while IFS= read -r line; do
9595
printf '%s\n' "$line"
9696

97-
while IFS=$(printf '\n') read -r TARGET; do
98-
if ! echo "$line" | grep -q "$TARGET"; then
97+
while IFS=$(printf '\n') read -r target; do
98+
if ! grep -Fq "$target" <<EOF
99+
$line
100+
EOF
101+
then
99102
continue
100103
fi
101104

102-
echo "\n======== entrypoint.sh ========\nentrypoint.sh: detected \"$TARGET\", exiting!\n================================"
105+
echo "\n======== entrypoint.sh ========\nentrypoint.sh: detected \"$target\", exiting!\n================================"
103106
rm -f $pipe
104107
kill "$SRV_PID"
105108
kill "$SHELL_PID"

readme.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,7 @@ A simple script will `rm -rf /home/5k/.wine` everytime before server starting
142142

143143
### Log Checker
144144

145-
A simple script will keep watching the stdout, and if it find any matched strings, it will kill the server
145+
A simple script will keep watching the stdout and stderr, and if it find any matched strings, it will kill the server
146146

147147
Default matched strings: `FOnlineAsyncTaskSteamCreateServer bWasSuccessful: 0`, `SteamSockets API: Error`
148148

@@ -291,7 +291,7 @@ docker run --name scp5kserver -p 7777:7777/tcp -p 7777:7777/udp -p 27015:27015/t
291291

292292
### Log Checker
293293

294-
一个简单的脚本,会持续监听标准输出(stdout),如果发现匹配的字符串,就会杀掉服务器
294+
一个简单的脚本,会持续监听标准输出(stdout)和标准错误(stderr),如果发现匹配的字符串,就会杀掉服务器
295295

296296
默认匹配字符串:`FOnlineAsyncTaskSteamCreateServer bWasSuccessful: 0`, `SteamSockets API: Error`
297297

0 commit comments

Comments
 (0)