Skip to content

Commit

Permalink
🔊 redirect games logs to container output (#31)
Browse files Browse the repository at this point in the history
* 🔊 redirect games logs to container output

* 📝 updated server log doc
  • Loading branch information
bgauduch authored Apr 27, 2020
1 parent 233b56a commit 24f5a13
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
17 changes: 11 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -42,17 +42,17 @@ FROM alpine:3.11.6
ARG COD2_VERSION
LABEL maintainer='bgauduch@github'

# setup the server non-root user
ENV SERVER_USER="cod2"
RUN addgroup -S ${SERVER_USER} && adduser -S -D -G ${SERVER_USER} ${SERVER_USER}
USER ${SERVER_USER}

# Copy needed libraries and binaries from build stage
COPY --from=build /usr/lib/i386-linux-gnu/ /usr/lib/i386-linux-gnu/
COPY --from=build /lib/i386-linux-gnu/ /lib/i386-linux-gnu/
COPY --from=build /lib/ld-linux.so.2 /lib/ld-linux.so.2
COPY --from=build /lib/libcod2_${COD2_VERSION}.so /lib/libcod2_${COD2_VERSION}.so
COPY --from=build /bin/cod2_lnxded /home/cod2/cod2_lnxded

# setup the server non-root user
ENV SERVER_USER="cod2"
RUN addgroup -S ${SERVER_USER} && adduser -S -D -G ${SERVER_USER} ${SERVER_USER}
USER ${SERVER_USER}
COPY --from=build /bin/cod2_lnxded /home/${SERVER_USER}/cod2_lnxded

# Exposed server ports
EXPOSE 20500/udp 20510/udp 28960/tcp 28960/udp
Expand All @@ -63,6 +63,11 @@ VOLUME [ "/home/${SERVER_USER}/main" ]
# Set the server dir
WORKDIR /home/${SERVER_USER}

# redirect server multiplayer logs to container stdout
RUN mkdir -p /home/${SERVER_USER}/.callofduty2/main/ \
&& touch /home/${SERVER_USER}/.callofduty2/main/games_mp.log \
&& ln -sf /dev/stdout /home/${SERVER_USER}/.callofduty2/main/games_mp.log

# Launch server at container startup using libcod library
ENV LD_PRELOAD="/lib/libcod2_1_3.so"
ENTRYPOINT [ "./cod2_lnxded" ]
11 changes: 10 additions & 1 deletion doc/readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -96,5 +96,14 @@ Kicks and temporarily bans player by client id from server
Unban every player banned with [name]. If you want to unban a single player whose name appears more than once, you should edit "ban.txt" manually.

## Server config
* `set fs_basepath`: set the game folder.
* `set fs_basepath`: set the game folder, where the `config` and `.iwd` files are.
* `set fs_homepath`: set the multiplayer log file and live config folder.

## Server logs
There is to type of logs:
* The **server** logs:
* It's the output of the server binary when executed.
* It contains server informations, map rotation, etc.
* The **game** logs:
* It's written by the server bynary to a file, created under `$fs_homepath/main/games_mp.log` by default.
* It contains all game information (kills, dammages, players join / quit, chat message, etc)
2 changes: 1 addition & 1 deletion docker-compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ services:
- "28960:28960/udp"
volumes:
- ./cod2server/main:/home/cod2/main:ro
# load the config as an argument to the entrypoint
# set server parameters as an argument to the entrypoint
command: ["+exec", "config.cfg"]
# Allow server shell interaction
stdin_open: true
Expand Down

0 comments on commit 24f5a13

Please sign in to comment.