[GH-ISSUE #786] Update feature : Online players check #630

Open
opened 2026-02-27 02:02:45 +03:00 by kerem · 19 comments
Owner

Originally created by @1stian on GitHub (Apr 22, 2016).
Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/786

Originally assigned to: @dgibbs64 on GitHub.

Hi,

I would like to see a feature that checks for online players on the server before it starts the update. If there are players online. We can have a choice of letting them know it will be updated in 5 mins or so. Or just abort the update and recheck later.

I think this will be really nice to have.

This is not really a issue more like a feature request.
Thanks.

Originally created by @1stian on GitHub (Apr 22, 2016). Original GitHub issue: https://github.com/GameServerManagers/LinuxGSM/issues/786 Originally assigned to: @dgibbs64 on GitHub. Hi, I would like to see a feature that checks for online players on the server before it starts the update. If there are players online. We can have a choice of letting them know it will be updated in 5 mins or so. Or just abort the update and recheck later. I think this will be really nice to have. This is not really a issue more like a feature request. Thanks.
Author
Owner

@dgibbs64 commented on GitHub (Apr 22, 2016):

I agree that would be a nice idea. Should be possible however Im not sure how to implement this yet.

<!-- gh-comment-id:213562946 --> @dgibbs64 commented on GitHub (Apr 22, 2016): I agree that would be a nice idea. Should be possible however Im not sure how to implement this yet.
Author
Owner

@UltimateByte commented on GitHub (Apr 22, 2016):

http://steamcommunity.com/groups/linuxgsm/discussions/0/364039531228165077/

Quotation from myself : "This would require to query the server and get the amount of players on it. I's an interesting idea but would be quite hard to do."

<!-- gh-comment-id:213566791 --> @UltimateByte commented on GitHub (Apr 22, 2016): http://steamcommunity.com/groups/linuxgsm/discussions/0/364039531228165077/ Quotation from myself : "This would require to query the server and get the amount of players on it. I's an interesting idea but would be quite hard to do."
Author
Owner

@1stian commented on GitHub (Apr 22, 2016):

@UltimateByte @dgibbs64 Yes. Querying a server from a script is not the easiest thing to do I guess. Anyway... I can experiment a little. By creating something that will run your update script, when the server is empty.. if I even are able to do that at all..

Anyway I hope it will be implemented if you have time or can ofc :)

Thanks.

<!-- gh-comment-id:213592862 --> @1stian commented on GitHub (Apr 22, 2016): @UltimateByte @dgibbs64 Yes. Querying a server from a script is not the easiest thing to do I guess. Anyway... I can experiment a little. By creating something that will run your update script, when the server is empty.. if I even are able to do that at all.. Anyway I hope it will be implemented if you have time or can ofc :) Thanks.
Author
Owner

@UltimateByte commented on GitHub (Apr 28, 2016):

Once again, Cedar has a clever idea about this : using "stats" command.

4:20 - CedarLUG: How to get # of players in (half life) game [referencing the github discussion[:
4:21 - CedarLUG: length=$(wc -l log/console/fof-server-console.log | awk '{print $1}')
4:21 - CedarLUG: tmux send-keys -t fof-server C-a C-k status Enter
4:21 - CedarLUG: tail -n+${length} log/console/fof-server-console.log | grep player | grep humans | tail -1 | awk -F"humans" '{print $1}' | cut -d: -f2
4:21 - CedarLUG: Probably a better way, but that's my first pass.
4:22 - CedarLUG: Works for CSGO, TF2, Fistful of Frags, etc.
4:28 - CedarLUG: the length captures the current size of the log file.
4:28 - CedarLUG: The tmux command issues C-a first (to set the cursor at the front of the line)
4:28 - CedarLUG: Then C-k to kill to the end of the line
4:29 - CedarLUG: (In case there's cruft on the line as described once by jballou)
4:29 - CedarLUG: Then issues "status"
4:29 - CedarLUG: That dumps to the console log, so the next part pulls the number of humans on the server.
4:30 - CedarLUG: The "tail -n+${length}" grabs only the log content that's "grown" since the length was set.
4:30 - CedarLUG: That's so that you don't parse the whole big file.
4:30 - CedarLUG: But there is a chance that another status was issued, so take the last one (tail -1)
4:31 - CedarLUG: parse it for player (not needed, but I had it in there)
4:31 - CedarLUG: and then cut the part of the line before "human" but after "players :"
4:31 - CedarLUG: That's the number of players currently tapped in.
4:31 - CedarLUG: Ez.

<!-- gh-comment-id:215397336 --> @UltimateByte commented on GitHub (Apr 28, 2016): Once again, Cedar has a clever idea about this : using "stats" command. > 4:20 - CedarLUG: How to get # of players in (half life) game [referencing the github discussion[: > 4:21 - CedarLUG: length=$(wc -l log/console/fof-server-console.log | awk '{print $1}') > 4:21 - CedarLUG: tmux send-keys -t fof-server C-a C-k status Enter > 4:21 - CedarLUG: tail -n+${length} log/console/fof-server-console.log | grep player | grep humans | tail -1 | awk -F"humans" '{print $1}' | cut -d: -f2 > 4:21 - CedarLUG: Probably a better way, but that's my first pass. > 4:22 - CedarLUG: Works for CSGO, TF2, Fistful of Frags, etc. > 4:28 - CedarLUG: the length captures the current size of the log file. > 4:28 - CedarLUG: The tmux command issues C-a first (to set the cursor at the front of the line) > 4:28 - CedarLUG: Then C-k to kill to the end of the line > 4:29 - CedarLUG: (In case there's cruft on the line as described once by jballou) > 4:29 - CedarLUG: Then issues "status" > 4:29 - CedarLUG: That dumps to the console log, so the next part pulls the number of humans on the server. > 4:30 - CedarLUG: The "tail -n+${length}" grabs only the log content that's "grown" since the length was set. > 4:30 - CedarLUG: That's so that you don't parse the whole big file. > 4:30 - CedarLUG: But there is a chance that another status was issued, so take the last one (tail -1) > 4:31 - CedarLUG: parse it for player (not needed, but I had it in there) > 4:31 - CedarLUG: and then cut the part of the line before "human" but after "players :" > 4:31 - CedarLUG: That's the number of players currently tapped in. > 4:31 - CedarLUG: Ez.
Author
Owner

@jaredballou commented on GitHub (May 9, 2016):

I use SteamCondenser in my stuff, but for a basic rcon implementation (in Node.js but easy to read), see https://github.com/randunel/node-srcds-rcon - we may want to create a function for rcon commands and use that to send and receive data to game instances. Using command stuffing and log scraping seems like a hacky approach. If I have some time (ha ha), I might try to add something like this.

<!-- gh-comment-id:217939750 --> @jaredballou commented on GitHub (May 9, 2016): I use SteamCondenser in my stuff, but for a basic rcon implementation (in Node.js but easy to read), see https://github.com/randunel/node-srcds-rcon - we may want to create a function for rcon commands and use that to send and receive data to game instances. Using command stuffing and log scraping seems like a hacky approach. If I have some time (ha ha), I might try to add something like this.
Author
Owner

@jaredballou commented on GitHub (May 19, 2016):

Also, there is this. I am using it to add these features to my forked gsquery.py:
https://github.com/Dasister/Source-Query-Class-Python/blob/master/QueryClass.py

<!-- gh-comment-id:220449753 --> @jaredballou commented on GitHub (May 19, 2016): Also, there is this. I am using it to add these features to my forked gsquery.py: https://github.com/Dasister/Source-Query-Class-Python/blob/master/QueryClass.py
Author
Owner

@dgibbs64 commented on GitHub (Jun 15, 2018):

Node-Gamedig is now supported. This feature should now be possible

<!-- gh-comment-id:397759568 --> @dgibbs64 commented on GitHub (Jun 15, 2018): Node-Gamedig is now supported. This feature should now be possible
Author
Owner

@dgibbs64 commented on GitHub (Jun 16, 2018):

#647 related

<!-- gh-comment-id:397815785 --> @dgibbs64 commented on GitHub (Jun 16, 2018): #647 related
Author
Owner

@dgibbs64 commented on GitHub (Nov 25, 2019):

Monitor has had a refactor and gamedig is better supported. This feature can now be developed for any game server that supports gamedig. However, will have to check results with bots

<!-- gh-comment-id:558141941 --> @dgibbs64 commented on GitHub (Nov 25, 2019): Monitor has had a refactor and gamedig is better supported. This feature can now be developed for any game server that supports gamedig. However, will have to check results with bots
Author
Owner

@dgibbs64 commented on GitHub (Sep 24, 2021):

gamedig support is much better in linuxgsm now. I will finally be looking to implement this functionality.

<!-- gh-comment-id:926933810 --> @dgibbs64 commented on GitHub (Sep 24, 2021): gamedig support is much better in linuxgsm now. I will finally be looking to implement this functionality.
Author
Owner

@1stian commented on GitHub (Sep 24, 2021):

gamedig support is much better in linuxgsm now. I will finally be looking to implement this functionality.

Oh wow! That would be awesome! Totally forgot about this... Been using LinuxGSM for years.. So this would be great! Thanks!

<!-- gh-comment-id:926949203 --> @1stian commented on GitHub (Sep 24, 2021): > gamedig support is much better in linuxgsm now. I will finally be looking to implement this functionality. Oh wow! That would be awesome! Totally forgot about this... Been using LinuxGSM for years.. So this would be great! Thanks!
Author
Owner

@dgibbs64 commented on GitHub (Sep 24, 2021):

Oh wow! That would be awesome! Totally forgot about this... Been using LinuxGSM for years.. So this would be great! Thanks!
Yeah I forgot about this and I have been developing LinuxGSM for years 😄

<!-- gh-comment-id:926951203 --> @dgibbs64 commented on GitHub (Sep 24, 2021): > Oh wow! That would be awesome! Totally forgot about this... Been using LinuxGSM for years.. So this would be great! Thanks! Yeah I forgot about this and I have been developing LinuxGSM for years 😄
Author
Owner

@dgibbs64 commented on GitHub (Feb 28, 2024):

So I am looking at this issue and so far I have gone with if players on the server then the server will not stop. This will cover all eventualities of stopping the server when a command is run. However the only issue is that an admin might WANT the server to stop even if players are still on the server. I am unsure how best to handle that

<!-- gh-comment-id:1969859236 --> @dgibbs64 commented on GitHub (Feb 28, 2024): So I am looking at this issue and so far I have gone with if players on the server then the server will not stop. This will cover all eventualities of stopping the server when a command is run. However the only issue is that an admin might WANT the server to stop even if players are still on the server. I am unsure how best to handle that
Author
Owner

@MicLieg commented on GitHub (Feb 28, 2024):

I think the most important thing is not to change the current default of stopping / restarting / updating the server even when players are connected to avoid breaking current setups.

So a new setting to choose whether to "force" / "wait for no players online" is probably needed. The default being to force stopping the server.

If an admin sets this to "wait for no players online" in the config, LinuxGSM users should be promoted when players are online to make sure they want to stop the server anyway. This behaviour should be overridable by adding an argument like ./gameserver restart force for automation.

This way, admins who want this functionality will also see any hints from the _default.cfg notifying them of breaking cronjobs if they decide to enable the feature.

Also it might be helpful to send alerts when stopping the server is delayed because of online players.

link #3676

<!-- gh-comment-id:1969954760 --> @MicLieg commented on GitHub (Feb 28, 2024): I think the most important thing is not to change the current default of stopping / restarting / updating the server even when players are connected to avoid breaking current setups. So a new setting to choose whether to "force" / "wait for no players online" is probably needed. The default being to force stopping the server. If an admin sets this to "wait for no players online" in the config, LinuxGSM users should be promoted when players are online to make sure they want to stop the server anyway. This behaviour should be overridable by adding an argument like .`/gameserver restart force` for automation. This way, admins who want this functionality will also see any hints from the `_default.cfg` notifying them of breaking cronjobs if they decide to enable the feature. Also it might be helpful to send alerts when stopping the server is delayed because of online players. link #3676
Author
Owner

@dgibbs64 commented on GitHub (Feb 28, 2024):

there will be a new var stoponlyifnoplayers="off" for admins to enable if they want.

I have just added some other functionality that if the server is blocked from restarting it will create a restart-request.lock file. When monitor is run it will check for this file and trigger a restart (if no players). This is useful if there is a daily restart cron that happens to run while players are on the server. It will ensure that the server will eventually be restarted.

Update will also only happen if no players are present. I expect as updates are released players will naturally drop off allowing the server to update itself without disturbing a running game.

I think adding force-restart and force-stop will also be needed.

Unsure on how to handle alerts currently but will give it some thought.

<!-- gh-comment-id:1969981549 --> @dgibbs64 commented on GitHub (Feb 28, 2024): there will be a new var `stoponlyifnoplayers="off"` for admins to enable if they want. I have just added some other functionality that if the server is blocked from restarting it will create a restart-request.lock file. When `monitor` is run it will check for this file and trigger a restart (if no players). This is useful if there is a daily restart cron that happens to run while players are on the server. It will ensure that the server will eventually be restarted. Update will also only happen if no players are present. I expect as updates are released players will naturally drop off allowing the server to update itself without disturbing a running game. I think adding `force-restart` and `force-stop` will also be needed. Unsure on how to handle alerts currently but will give it some thought.
Author
Owner

@MicLieg commented on GitHub (Feb 28, 2024):

Sounds good!

I expect as updates are released players will naturally drop off allowing the server to update itself without disturbing a running game.

Perhaps this can also be achieved by adding a maxstopdelay var to the config, forcing the server to restart, stop or update after the desired period of time.

<!-- gh-comment-id:1970005863 --> @MicLieg commented on GitHub (Feb 28, 2024): Sounds good! > I expect as updates are released players will naturally drop off allowing the server to update itself without disturbing a running game. Perhaps this can also be achieved by adding a `maxstopdelay` var to the config, forcing the server to `restart`, `stop` or `update` after the desired period of time.
Author
Owner

@dgibbs64 commented on GitHub (Jun 16, 2024):

So there a a few scenarios to this

  1. stop command will not stop the server if players are on the server
  2. restart command will postpone a restart of the server if players on the server (lock file is created). Monitor will check for an empty server and then force a restart.
  3. update command will not update if players are on the server (lock file is created). Monitor will check for an empty server and then force an update.

Edit: add timeout setting to force restart after X mintues

<!-- gh-comment-id:2171831920 --> @dgibbs64 commented on GitHub (Jun 16, 2024): So there a a few scenarios to this 1. stop command will not stop the server if players are on the server 2. restart command will postpone a restart of the server if players on the server (lock file is created). Monitor will check for an empty server and then force a restart. 3. update command will not update if players are on the server (lock file is created). Monitor will check for an empty server and then force an update. Edit: add timeout setting to force restart after X mintues
Author
Owner

@MicLieg commented on GitHub (Jun 17, 2024):

Tanks for your effort! @dgibbs64

I still think it might be useful to be able to set a grace period in the config, after which a restart, stop or update is forced even if players are connected. Otherwise, a daily restart will be impossible in some cases, as some players will stay AFK/online overnight.

<!-- gh-comment-id:2172602278 --> @MicLieg commented on GitHub (Jun 17, 2024): Tanks for your effort! @dgibbs64 I still think it might be useful to be able to set a grace period in the config, after which a `restart`, `stop` or `update` is forced even if players are connected. Otherwise, a daily restart will be impossible in some cases, as some players will stay AFK/online overnight.
Author
Owner

@dgibbs64 commented on GitHub (Jun 17, 2024):

I agree I will add that functionality

<!-- gh-comment-id:2172714133 --> @dgibbs64 commented on GitHub (Jun 17, 2024): I agree I will add that functionality
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#630
No description provided.