Skip to content

Commit 8fcdab7

Browse files
committed
refactor: improve exit handler and log tailing
- Renamed the `exit_handler` function to `exit_handler_user` in `entrypoint-user.sh` - Updated the echo statements in the exit handler to use proper capitalization - Removed unnecessary `exec` command in the exit handler of both scripts - Modified trap signal from `exit_handler` to `exit_handler_user` in `entrypoint-user.sh` - Added background execution for log tailing in both scripts using `tail -F` - Added wait command at the end of each script to ensure completion
1 parent 9a0cdef commit 8fcdab7

File tree

2 files changed

+9
-7
lines changed

2 files changed

+9
-7
lines changed

entrypoint-user.sh

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
#!/bin/bash
22

3-
exit_handler() {
3+
exit_handler_user() {
44
# Execute the shutdown commands
5-
echo -e "stopping ${GAMESERVER}"
6-
exec gosu "${USERNAME}" ./"${GAMESERVER}" stop
5+
echo -e "Stopping ${GAMESERVER}"
6+
./"${GAMESERVER}" stop
77
exitcode=$?
88
exit ${exitcode}
99
}
1010

1111
# Exit trap
1212
echo -e "Loading exit handler"
13-
trap exit_handler SIGQUIT SIGINT SIGTERM
13+
trap exit_handler_user SIGQUIT SIGINT SIGTERM
1414

1515
# Setup game server
1616
if [ ! -f "${GAMESERVER}" ]; then
@@ -64,4 +64,5 @@ sleep 5
6464
sleep 2
6565
echo -e "Tail log files"
6666
echo -e "================================="
67-
tail -F log/*/*.log
67+
tail -F log/*/*.log &
68+
wait

entrypoint.sh

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
exit_handler() {
44
# Execute the shutdown commands
5-
echo -e "stopping ${GAMESERVER}"
5+
echo -e "Stopping ${GAMESERVER}"
66
exec gosu "${USERNAME}" ./"${GAMESERVER}" stop
77
exitcode=$?
88
exit ${exitcode}
@@ -59,4 +59,5 @@ export HOME=/data
5959
echo -e ""
6060
echo -e "Switch to user ${USERNAME}"
6161
echo -e "================================="
62-
exec gosu "${USERNAME}" /app/entrypoint-user.sh
62+
exec gosu "${USERNAME}" /app/entrypoint-user.sh &
63+
wait

0 commit comments

Comments
 (0)