[GH-ISSUE #4680] [Bug]: Unable to start multiple instances of Core Keeper due to xvfb-run #2908

Open
opened 2026-02-27 03:06:13 +03:00 by kerem · 1 comment
Owner

Originally created by @Crimson-Decoded on GitHub (Oct 1, 2024).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/4680

User story

As a server admin, I want to be able to start multiple instances of Core Keeper server

Game

Core Keeper

Linux distro

Ubuntu 22.04, Other

Command

command: start, command: monitor

Further information

Note, this may not affect only core keeper, but could potentially affect ANY game server that uses xvfb-run

xvfb-run, which is used as the preexecutable for Core Keeper server, has a limitation in that running just the command alone will attempt to create and use x server number 99. However only one xvfb-run can only use one x server, therefore when attempting to start a second instance of Core Keeper, it fails to start citing xvfb-run: error: Xvfb failed to start

xvfb-run -a should be the bare minimum, as this allows xvfb-run to auto select an x server, from 99 to 599, starting at 99, and incrementing until it finds an open x server.
xvfb-run -n ### lets you specify an x server number, but hard coding this is effectively the same as not selecting any x server.
xvfb-run -a -n ### is the combination of both, where it selects a random x server, starting at ###, incrementing until it finds an open x server

However, this is also partially flawed, as two xvfb-run -a running simultaneously (such as with a systemd unit on boot) will not account for each other, and may end up selecting the same x server number, resulting in one still failing.

I don't know if there's a truly fool-proof way to mitigate this. using xvfb-run -a -n $(shuf -i100-599 -n1) (or whatever random range method preferred) should mostly mitigate this, however there is still the off chance that both end up generating the same random number due to the relatively small scope (compared to the normal range for random numbers), and therefore can still collide when starting simultaneously.
Alternatively, this may be possible by fuzzing the start time of core keeper by a random number of seconds, say... somewhere between 5 and 45s. Probably don't want this too large, because then people that use monitor cron jobs might have issues. But again, due to the small scope, duplicate randoms are possible, even if unlikely.

In theory, standard PRNG uses the PID and nanosecond time to generate a number, so even two starting parallel at the same nanosecond time should be different values, however that's assuming the standard range that the PRNG algorithm uses. When shortening the range, regardless of method used, the likelihood of two simultaneous randoms being the same becomes more likely.

I don't know if there's a "best" way to prevent xvfb-run x server issues, or a way to guarantee no overlap other than selecting static server numbers per instance, but that would need to be done by the user. That is an option, though.

Perhaps just making a variable in the Predefined Parameters in the config like:

# Change this to a unique number between 99 and 599 for each instance of Core Keeper
xservnum="199"

Then change the preexecutable to
xvfb-run -a -n ${xservnum}

Relevant log output

No response

Steps to reproduce

  1. Create and start one Core Keeper server
  2. Create and attempt to start another Core Keeper server
  3. Review console logs to see xvfb-run: error: Xvfb failed to start
Originally created by @Crimson-Decoded on GitHub (Oct 1, 2024). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/4680 ### User story As a server admin, I want to be able to start multiple instances of Core Keeper server ### Game Core Keeper ### Linux distro Ubuntu 22.04, Other ### Command command: start, command: monitor ### Further information Note, this may not affect only core keeper, but could potentially affect ANY game server that uses xvfb-run xvfb-run, which is used as the preexecutable for Core Keeper server, has a limitation in that running just the command alone will attempt to create and use x server number 99. However only one xvfb-run can only use one x server, therefore when attempting to start a second instance of Core Keeper, it fails to start citing `xvfb-run: error: Xvfb failed to start` `xvfb-run -a` should be the bare minimum, as this allows xvfb-run to auto select an x server, from 99 to 599, starting at 99, and incrementing until it finds an open x server. `xvfb-run -n ###` lets you specify an x server number, but hard coding this is effectively the same as not selecting any x server. `xvfb-run -a -n ###` is the combination of both, where it selects a random x server, starting at ###, incrementing until it finds an open x server However, this is also partially flawed, as two `xvfb-run -a` running simultaneously (such as with a systemd unit on boot) will not account for each other, and may end up selecting the same x server number, resulting in one still failing. I don't know if there's a truly fool-proof way to mitigate this. using `xvfb-run -a -n $(shuf -i100-599 -n1)` (or whatever random range method preferred) should mostly mitigate this, however there is still the off chance that both end up generating the same random number due to the relatively small scope (compared to the normal range for random numbers), and therefore can still collide when starting simultaneously. Alternatively, this may be possible by fuzzing the start time of core keeper by a random number of seconds, say... somewhere between 5 and 45s. Probably don't want this too large, because then people that use monitor cron jobs might have issues. But again, due to the small scope, duplicate randoms are possible, even if unlikely. In theory, standard PRNG uses the PID and nanosecond time to generate a number, so even two starting parallel at the same nanosecond time should be different values, however that's assuming the standard range that the PRNG algorithm uses. When shortening the range, regardless of method used, the likelihood of two simultaneous randoms being the same becomes more likely. I don't know if there's a "best" way to prevent xvfb-run x server issues, or a way to guarantee no overlap other than selecting static server numbers per instance, but that would need to be done by the user. That is an option, though. Perhaps just making a variable in the Predefined Parameters in the config like: ``` # Change this to a unique number between 99 and 599 for each instance of Core Keeper xservnum="199" ``` Then change the preexecutable to `xvfb-run -a -n ${xservnum}` ### Relevant log output _No response_ ### Steps to reproduce 1. Create and start one Core Keeper server 2. Create and attempt to start another Core Keeper server 3. Review console logs to see `xvfb-run: error: Xvfb failed to start`
Author
Owner

@Crimson-Decoded commented on GitHub (Oct 1, 2024):

I myself didn't have the issue, but helped a user solve it here
https://discord.com/channels/127498813903601664/1290346537104314472/1290346537104314472

<!-- gh-comment-id:2387077630 --> @Crimson-Decoded commented on GitHub (Oct 1, 2024): I myself didn't have the issue, but helped a user solve it here https://discord.com/channels/127498813903601664/1290346537104314472/1290346537104314472
Sign in to join this conversation.
No labels
Atomic
Epic
cannot reproduce
command: backup
command: console
command: debug
command: details
command: fast-dl
command: install
command: mods
command: monitor
command: post-details
command: restart
command: send
command: start
command: stop
command: update
command: update-lgsm
command: validate
command: wipe
distro: AlmaLinux
distro: Arch Linux
distro: CentOS
distro: Debian
distro: Fedora
distro: RedHat
distro: Rocky Linux
distro: Ubuntu
distro: openSUSE
engine: goldsrc
engine: source
game: 7 Days to Die
game: ARMA 3
game: Ark: Survival Evolved
game: Assetto Corsa
game: Avorion
game: BATTALION: Legacy
game: Barotrauma
game: Battalion 1944
game: Battlefield 1942
game: Black Mesa: Deathmatch
game: Blade Symphony
game: Call of Duty 2
game: Call of Duty 4
game: Call of Duty: United Offensive
game: Counter-Strike 1.6
game: Counter-Strike 2
game: Counter-Strike: Global Offensive
game: Counter-Strike: Source
game: Day of Infamy
game: Dayz
game: Death Match Classic
game: Don't Starve Together
game: ET: Legacy
game: Eco
game: Factorio
game: Factorio
game: Garry's Mod
game: Half-Life
game: Hurtword
game: Insurgecy
game: Insurgecy
game: Insurgency: Sandstorm
game: Just Cause 3
game: Killing Floor
game: Killing Floor 2
game: Left 4 Dead 2
game: Minecraft
game: Minecraft Bedrock
game: Mordhau
game: Multi Theft Auto
game: Mumble
game: Natural Selection 2
game: No More Room in Hell
game: Pavlov VR
game: Post Scriptum
game: Project Zomboid
game: Quake 3
game: QuakeWorld
game: Red Orchestra: Ostfront 41-45
game: Return to Castle Wolfenstein
game: Rising World
game: Rust
game: San Andreas Multiplayer
game: Satisfactory
game: Soldat
game: Soldier of Fortune 2
game: Squad
game: Squad 44
game: Starbound
game: Stationeers
game: Sven Co-op
game: Team Fortress 2
game: Teamspeak 3
game: Teeworlds
game: Terraria
game: The Front
game: Unreal Tournament 2004
game: Unreal Tournament 3
game: Unreal Tournament 99
game: Unturned
game: Valheim
game: Wurm Unlimited
game: Zombie Master Reborn
game: label missing
good first issue
help wanted
info: alerts
info: dependency
info: docker
info: docs
info: email
info: query
info: steamcmd
info: systemd
info: tmux
info: website
info: website
needs more info
outcome: duplicate
outcome: issue resolved
outcome: issue resolved
outcome: issue unresolved
outcome: pr accepted
outcome: pr rejected
outcome: unconfirmed
outcome: wontfix
outcome: wrong forum
potential-duplicate
priority
pull-request
type: bug
type: feature
type: feature
type: feature request
type: game server request
type: refactor
waiting response
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference
starred/LinuxGSM#2908
No description provided.