Skip to content

Commit 49f1c4f

Browse files
committed
Update to 1.22.0 and improve server management with graceful shutdown, vs-cli utility for sending commands
1 parent 6f2416a commit 49f1c4f

5 files changed

Lines changed: 72 additions & 22 deletions

File tree

‎Dockerfile‎

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,25 @@
1-
FROM mcr.microsoft.com/dotnet/runtime:8.0
1+
FROM mcr.microsoft.com/dotnet/runtime:10.0
22

33
# Env var
44
ENV SERVER_BRANCH="stable" \
5-
SERVER_VERSION="1.21.1" \
5+
SERVER_VERSION="1.22.0" \
66
SERVER_PORT="42420" \
77
WORLDCONFIG_PROPICK_NODE_SEARCH_RADIUS="6" \
88
UID="1000" \
99
GID="1000"
1010

1111
# Install dependencies
1212
RUN apt-get update && \
13-
apt-get install --no-install-recommends -y wget netcat-traditional jq moreutils && \
13+
apt-get install --no-install-recommends -y wget netcat-traditional jq moreutils screen && \
1414
apt-get clean autoclean && \
1515
apt-get autoremove -y && \
1616
rm -rf /var/lib/apt/lists/* && \
1717
mkdir /data && mkdir /data/server-file && \
1818
touch /data/server-file/.version
1919

2020
# Add User
21-
RUN useradd -u $UID -U -m -s /bin/false vintagestory && usermod -G users vintagestory && \
21+
RUN userdel -r ubuntu 2>/dev/null || true && groupdel ubuntu 2>/dev/null || true && \
22+
useradd -u $UID -U -m -s /bin/false vintagestory && usermod -G users vintagestory && \
2223
chown -R vintagestory:vintagestory /data
2324

2425
# Expose ports
@@ -27,9 +28,15 @@ EXPOSE 42420
2728
# Healthcheck
2829
HEALTHCHECK --start-period=1m --interval=5s CMD nc -z 127.0.0.1 $SERVER_PORT
2930

31+
STOPSIGNAL SIGTERM
32+
3033
VOLUME ["/data/server-file"]
3134

3235
COPY serverconfig.json /data/default-serverconfig.json
3336

3437
COPY entry.sh /data/scripts/entry.sh
38+
39+
COPY vs-cli.sh /usr/local/bin/vs-cli
40+
RUN chmod +x /usr/local/bin/vs-cli
41+
3542
CMD ["bash", "/data/scripts/entry.sh"]

‎entry.sh‎

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,13 @@
11
#!/bin/sh
22

3+
# Graceful stop function
4+
graceful_stop() {
5+
echo "Stopping server..."
6+
su vintagestory -s /bin/sh -p -c "screen -S vsserver -X stuff '/stop\n'"
7+
wait $SERVER_PID
8+
exit 0
9+
}
10+
311
# Ensure User and Group IDs
412
if [ ! "$(id -u vintagestory)" -eq "$UID" ]; then usermod -o -u "$UID" vintagestory ; fi
513
if [ ! "$(id -g vintagestory)" -eq "$GID" ]; then groupmod -o -g "$GID" vintagestory ; fi
@@ -122,7 +130,22 @@ if [ -n "$WORLDCONFIG_ALLOW_LAND_CLAIMING" ]; then jq '.WorldConfig.WorldConfigu
122130
if [ -n "$WORLDCONFIG_CLASS_EXCLUSIVE_RECIPES" ]; then jq '.WorldConfig.WorldConfiguration.classExclusiveRecipes = ($val | test("true"))' --arg val "$WORLDCONFIG_CLASS_EXCLUSIVE_RECIPES" $serverconfig | sponge $serverconfig ; fi
123131
if [ -n "$WORLDCONFIG_AUCTION_HOUSE" ]; then jq '.WorldConfig.WorldConfiguration.auctionHouse = ($val | test("true"))' --arg val "$WORLDCONFIG_AUCTION_HOUSE" $serverconfig | sponge $serverconfig ; fi
124132

133+
# FIFO pipe
134+
mkfifo /tmp/vsserver-log
135+
chmod 666 /tmp/vsserver-log
136+
137+
# Trap signal
138+
trap graceful_stop SIGTERM
139+
125140
# Start server
126141
echo "Launching server..."
127142
cd /data
128-
su vintagestory -s /bin/sh -p -c "dotnet VintagestoryServer.dll --dataPath /data/server-file"
143+
144+
su vintagestory -s /bin/sh -p -c '
145+
cat /tmp/vsserver-log &
146+
screen -DmS vsserver sh -c "dotnet VintagestoryServer.dll --dataPath /data/server-file | tee /tmp/vsserver-log"
147+
' &
148+
149+
SERVER_PID=$!
150+
151+
wait $SERVER_PID

‎readme.md‎

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -127,12 +127,9 @@ services:
127127
128128
# Help
129129
130-
## Server console
130+
## Send command to the server console
131131
132-
You need `stdin_open` and `tty` to true in docker compose file.
132+
To send a command to the server, you need to use vs-cli with docker exec
133133
134-
To interact with the console, you need to attach to the container, replace <container_name> with your container name.
134+
```docker exec <container_name> vs-cli "<cmd>"```
135135

136-
```docker attach <container_name>```
137-
138-
Use Control-p Control-q to detach.

‎serverconfig.json‎

Lines changed: 27 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,20 @@
11
{
22
"FileEditWarning": "",
3-
"ConfigVersion": "1.7",
3+
"ConfigVersion": "1.10",
44
"ServerName": "Vintage Story Server",
55
"ServerUrl": null,
66
"ServerDescription": null,
77
"WelcomeMessage": "Welcome {0}, may you survive well and prosper",
88
"Ip": null,
99
"Port": 42420,
1010
"Upnp": false,
11+
"UpnpInfiniteLifetime": false,
1112
"CompressPackets": true,
1213
"AdvertiseServer": true,
1314
"MaxClients": 16,
15+
"MaxClientsInQueue": 0,
16+
"WarnClientsAfterAfkSeconds": 0,
17+
"KickClientsAfterAfkSeconds": 0,
1418
"PassTimeWhenEmpty": false,
1519
"MasterserverUrl": "http://masterserver.vintagestory.at/api/v1/servers/",
1620
"ModDbUrl": "https://mods.vintagestory.at/",
@@ -23,8 +27,8 @@
2327
"ServerLanguage": "en",
2428
"MaxChunkRadius": 12,
2529
"TickTime": 33.333332,
26-
"SpawnCapPlayerScaling": 0.75,
27-
"BlockTickChunkRange": 4,
30+
"SpawnCapPlayerScaling": 0.5,
31+
"BlockTickChunkRange": 5,
2832
"MaxMainThreadBlockTicks": 10000,
2933
"RandomBlockTicksPerChunk": 16,
3034
"BlockTickInterval": 300,
@@ -201,12 +205,13 @@
201205
"Code": "sumod",
202206
"PrivilegeLevel": 200,
203207
"Name": "Survival Moderator",
204-
"Description": "Can use/place/break blocks everywhere (priv level 200), create/manage player groups, chat, kick/ban players and do serverwide announcements. Can claim an area of up to 4 chunks.",
208+
"Description": "Can use/place/break blocks everywhere (priv level 200), create/manage own/other player groups, chat, kick/ban players and do serverwide announcements. Can claim an area of up to 4 chunks.",
205209
"DefaultSpawn": null,
206210
"ForcedSpawn": null,
207211
"Privileges": [
208212
"controlplayergroups",
209213
"manageplayergroups",
214+
"manageotherplayergroups",
210215
"chat",
211216
"areamodify",
212217
"build",
@@ -237,12 +242,13 @@
237242
"Code": "crmod",
238243
"PrivilegeLevel": 500,
239244
"Name": "Creative Moderator",
240-
"Description": "Can use/place/break blocks everywhere (priv level 500), create/manage player groups, chat, kick/ban players, fly and set his own or other players game modes (= allows fly and change of move speed). Can claim an area of up to 40 chunks.",
245+
"Description": "Can use/place/break blocks everywhere (priv level 500), create/manage own/other player groups, chat, kick/ban players, fly and set his own or other players game modes (= allows fly and change of move speed). Can claim an area of up to 40 chunks.",
241246
"DefaultSpawn": null,
242247
"ForcedSpawn": null,
243248
"Privileges": [
244249
"controlplayergroups",
245250
"manageplayergroups",
251+
"manageotherplayergroups",
246252
"chat",
247253
"areamodify",
248254
"build",
@@ -308,6 +314,7 @@
308314
"controlplayergroups",
309315
"manageplayergroups",
310316
"selfkill",
317+
"manageotherplayergroups",
311318
"worldedit"
312319
],
313320
"RuntimePrivileges": [],
@@ -330,30 +337,34 @@
330337
],
331338
"AntiAbuse": 0,
332339
"WorldConfig": {
333-
"Seed": "",
340+
"Seed": null,
334341
"SaveFileLocation": "/data/server-file/Saves/default.vcdbs",
335342
"WorldName": "A new world",
336343
"AllowCreativeMode": true,
337344
"PlayStyle": "surviveandbuild",
338-
"PlayStyleLangCode": "preset-surviveandbuild",
345+
"PlayStyleLangCode": "surviveandbuild-bands",
339346
"WorldType": "standard",
340-
"WorldConfiguration": null,
341-
"MapSizeY": 256,
342-
"CreatedByPlayerName": "",
343-
"DisabledMods": [],
347+
"WorldConfiguration": {
348+
"propickNodeSearchRadius": "6"
349+
},
350+
"MapSizeY": null,
351+
"CreatedByPlayerName": null,
352+
"DisabledMods": null,
344353
"RepairMode": false
345354
},
346355
"NextPlayerGroupUid": 10,
347356
"GroupChatHistorySize": 20,
348357
"MaxOwnedGroupChannelsPerUser": 10,
349358
"OnlyWhitelisted": false,
359+
"WhitelistMode": 1,
350360
"VerifyPlayerAuth": true,
351361
"DefaultSpawn": null,
352362
"AllowPvP": true,
353363
"AllowFireSpread": true,
354364
"AllowFallingBlocks": true,
355365
"HostedMode": false,
356366
"HostedModeAllowMods": false,
367+
"VhIdentifier": null,
357368
"StartupCommands": null,
358369
"RepairMode": false,
359370
"AnalyzeMode": false,
@@ -362,8 +373,13 @@
362373
"ChatRateLimitMs": 1000,
363374
"DieBelowDiskSpaceMb": 400,
364375
"ModIdBlackList": null,
376+
"ModIdWhiteList": null,
365377
"LogBlockBreakPlace": false,
366378
"LogFileSplitAfterLine": 500000,
367379
"DieAboveErrorCount": 100000,
380+
"LoginFloodProtection": false,
381+
"TemporaryIpBlockList": false,
382+
"DisableModSafetyCheck": false,
383+
"DisableAutoRemap": false,
368384
"DieAboveMemoryUsageMb": 50000
369385
}

‎vs-cli.sh‎

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
#!/bin/sh
2+
if [ -z "$1" ]; then
3+
echo "Usage: $0 <command>"
4+
exit 1
5+
fi
6+
7+
su vintagestory -s /bin/sh -c "screen -S vsserver -X stuff \"$(printf '%s' "$1")\n\""

0 commit comments

Comments
 (0)