Skip to content

Commit

Permalink
Merge pull request #5 from jsknnr/dev
Browse files Browse the repository at this point in the history
additional logging, additional documentation, better shutdown handling
  • Loading branch information
jsknnr authored Jun 1, 2024
2 parents da842c2 + 3149b22 commit 2d8095b
Show file tree
Hide file tree
Showing 7 changed files with 53 additions and 12 deletions.
7 changes: 5 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ Game ports are arbitrary. You can use which ever values you want above 1000. Mak
| SERVER_LEVEL | Level for server to load. Currently there is only 1 so no need to change | Level01_Main | False |
| GAME_PORT | Port for server connections | 27050 | False |
| QUERY_PORT | Port for steam query of server | 27051 | False |
| SERVER_SLOTS | Number of slots for connections (Max 50) | 50 | False |
| SERVER_SLOTS | Number of slots for connections (Max 70) | 50 | False |
| LISTEN_ADDRESS | IP address for server to listen on | 0.0.0.0 | False |

### Docker
Expand All @@ -53,6 +53,7 @@ docker run \
--env=GAME_PORT=27050 \
--env=QUERY_PORT=27051 \
--env=LISTEN_ADDRESS='0.0.0.0' \
--stop-timeout 90 \
sknnr/soulmask-dedicated-server:latest
```

Expand All @@ -67,7 +68,7 @@ docker-compose up -d
To bring the container down:

```bash
docker-compose down
docker-compose down --timeout 90
```

compose.yaml file:
Expand All @@ -82,6 +83,7 @@ services:
- default.env
volumes:
- soulmask-persistent-data:/home/steam/soulmask
stop_grace_period: 90s

volumes:
soulmask-persistent-data:
Expand Down Expand Up @@ -119,6 +121,7 @@ podman run \
--env=GAME_PORT=27050 \
--env=QUERY_PORT=27051 \
--env=LISTEN_ADDRESS='0.0.0.0' \
--stop-timeout 90 \
docker.io/sknnr/soulmask-dedicated-server:latest
```

Expand Down
2 changes: 1 addition & 1 deletion container/Containerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
FROM debian:12-slim

ARG IMAGE_VERSION="v1.0.0"
ARG IMAGE_VERSION="v1.0.0-devel"
ARG MAINTAINER="https://github.com/jsknnr/soulmask-dedicated-server"

ARG CONTAINER_GID=10000
Expand Down
1 change: 1 addition & 0 deletions container/compose.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ services:
- default.env
volumes:
- soulmask-persistent-data:/home/steam/soulmask
stop_grace_period: 90s

volumes:
soulmask-persistent-data:
2 changes: 1 addition & 1 deletion container/default.env
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ SERVER_PASSWORD="ChangeMePlease"
ADMIN_PASSWORD="AdminChangeMePlease"
GAME_PORT="27050"
QUERY_PORT="27051"
SERVER_SLOTS="70"
SERVER_SLOTS="50"
LISTEN_ADDRESS="0.0.0.0"
22 changes: 18 additions & 4 deletions container/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ shutdown () {
echo ""
echo "$(timestamp) INFO: Recieved SIGTERM, shutting down gracefully"
kill -2 $soulmask_pid
tail --pid=$soulmask_pid -f /dev/null
echo "$(timestamp) INFO: Shutdown complete"
}

# Set our trap
Expand Down Expand Up @@ -44,7 +42,6 @@ if [ -z "$GAME_MODE" ]; then
echo "$(timestamp) ERROR: GAME_MODE not set, must be 'pve' or 'pvp'"
exit 1
else
echo $GAME_MODE
if [ "$GAME_MODE" != "pve" ] && [ "$GAME_MODE" != "pvp" ]; then
echo "$(timestamp) ERROR: GAME_MODE must be either 'pve' or 'pvp'"
exit 1
Expand All @@ -66,12 +63,16 @@ rm "${SOULMASK_PATH}/test"

# Install/Update Soulmask
echo "$(timestamp) INFO: Updating Soulmask Dedicated Server"
echo ""
${STEAMCMD_PATH}/steamcmd.sh +force_install_dir "${SOULMASK_PATH}" +login anonymous +app_update ${STEAM_APP_ID} validate +quit
echo ""

# Check that steamcmd was successful
if [ $? != 0 ]; then
echo "$(timestamp) ERROR: steamcmd was unable to successfully initialize and update Soulmask"
exit 1
else
echo "$(timestamp) INFO: steamcmd update of Soulmask successful"
fi

# Build launch arguments
Expand All @@ -82,6 +83,9 @@ if [ -n "${SERVER_PASSWORD}" ]; then
LAUNCH_ARGS="${LAUNCH_ARGS} -PSW=${SERVER_PASSWORD}"
fi

# Let's go!
echo "$(timestamp) INFO: Lighting the bonfire..."

# Cheesy asci launch banner because I remember 1999
echo ""
echo ""
Expand All @@ -93,7 +97,7 @@ echo "/_______ /\_______ /______/ |_______ \____|__ /\____|__ /_______ /___
echo " \/ \/ \/ \/ \/ \/ \/"
echo " "
echo " "
echo "$(timestamp) INFO: Launching Soulmask"
echo "$(timestamp) INFO: Launching Soulmask. Good luck out there, Chieftan!"
echo "--------------------------------------------------------------------------------"
echo "Server Name: ${SERVER_NAME}"
echo "Game Mode: ${GAME_MODE}"
Expand All @@ -104,6 +108,7 @@ echo "Game Port: ${GAME_PORT}"
echo "Query Port: ${QUERY_PORT}"
echo "Server Slots: ${SERVER_SLOTS}"
echo "Listen Address: ${LISTEN_ADDRESS}"
echo "Container Image Version: ${IMAGE_VERSION} "
echo "--------------------------------------------------------------------------------"
echo ""
echo ""
Expand All @@ -128,4 +133,13 @@ while [ $timeout -lt 11 ]; do
((timeout++))
done

# Hold us open until we recieve a SIGTERM
wait $init_pid

# Handle post SIGTERM from here
# Hold us open until WSServer-Linux pid closes, indicating full shutdown, then go home
tail --pid=$soulmask_pid -f /dev/null

# o7
echo "$(timestamp) INFO: Shutdown complete. Goodbye, Chieftan."
exit 0
1 change: 1 addition & 0 deletions helm/templates/depolyment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -66,3 +66,4 @@ spec:
- name: data
persistentVolumeClaim:
claimName: "{{ .Chart.Name }}-data"
terminationGracePeriodSeconds: 90
30 changes: 26 additions & 4 deletions makefile
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,16 @@
REGISTRY := "localhost"
IMAGE := "soulmask-test"
IMAGE_REF := $(REGISTRY)/$(IMAGE)
GIT_HASH := $(shell git rev-parse --short=8 HEAD)

# Podman Options
CONTAINER_NAME := "soulmask-dev"
VOLUME_NAME := "soulmask-data-dev"
PODMAN_BUILD_OPTS := --format docker -f ./container/Containerfile
PODMAN_RUN_OPTS := --name $(CONTAINER_NAME) -d --mount type=volume,source=$(VOLUME_NAME),target=/home/steam/soulmask
PODMAN_BUILD_OPTS := --build-arg="IMAGE_VERSION=$(GIT_HASH)-devel" --format docker -f ./container/Containerfile
PODMAN_RUN_OPTS := --name $(CONTAINER_NAME) --env=GAME_MODE="pve" --stop-timeout 90 -d --mount type=volume,source=$(VOLUME_NAME),target=/home/steam/soulmask

# Makefile targets
.PHONY: build run cleanup
.PHONY: build run run-no-vol clean-all clean-build clean-volume clean-image

build:
podman build $(PODMAN_BUILD_OPTS) -t $(IMAGE_REF):latest ./container
Expand All @@ -21,7 +22,28 @@ run:
podman volume create $(VOLUME_NAME)
podman run $(PODMAN_RUN_OPTS) $(IMAGE_REF):latest

cleanup:
run-no-vol:
podman run $(PODMAN_RUN_OPTS) $(IMAGE_REF):latest

# Clean all artifacts
clean-all:
podman rm -f $(CONTAINER_NAME)
podman rmi -f $(IMAGE_REF):latest
podman volume rm $(VOLUME_NAME)

# Clean container and volume
clean-build:
podman rm -f $(CONTAINER_NAME)
podman volume rm $(VOLUME_NAME)

# Clean container
clean-container:
podman rm -f $(CONTAINER_NAME)

# Clean volume
clean-volume:
podman volume rm $(VOLUME_NAME)

# Clean image
clean-image:
podman rmi -f $(IMAGE_REF):latest

0 comments on commit 2d8095b

Please sign in to comment.