Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Warn players when manually stopping server #196

Open
1 task done
Br31zh opened this issue Jan 20, 2023 · 4 comments
Open
1 task done

Warn players when manually stopping server #196

Br31zh opened this issue Jan 20, 2023 · 4 comments
Labels
enhancement New feature or request request User's suggested enhancement

Comments

@Br31zh
Copy link

Br31zh commented Jan 20, 2023

Is there an existing feature request for this?

  • I have searched the existing issues before opening this feature request.

Describe the feature you would like to see.

When I stop the server manually (system reboot, maintenance, mods upgrade…), I would like to warn connected players, if there is any (otherwise, or if it’s frozen, then stop it directly).

Describe the solution you'd like.

Maybe two options: warn delay, warn message? Eventually, changing the MOTD and/or prevent users to login during this time.

Another way is to allow to use an external program to stop the server (like the start command). And add some commands to the msh shell too (like one to change the MOTD). That way it would be even more customizable (but then it’s another request I guess).

Additional context to this request.

No response

@gekigek99
Copy link
Member

add some commands to the msh shell too (like one to change the MOTD). That way it would be even more customizable (but then it’s another request I guess).

yeah can you open an other request for that?

@gekigek99
Copy link
Member

Maybe two options: warn delay, warn message? Eventually, changing the MOTD and/or prevent users to login during this time.

Idk... why do you need it? If you really have to stop the server immediately then you wont wait anyway for players, plus even with a forceful shutdown msh tries to save the world so no data lost.

It might make admin life a bit weird as when msh receive a ctrl+c signal it would have to wait 30 or so seconds after player warning

@Br31zh
Copy link
Author

Br31zh commented Jan 24, 2023

I have two OSes on the computer that run Minecraft, and I often (several times a week, sometimes even twice in the same day) need to reboot from one to the another. And I don’t want to kick all players without any warning that often. This delay give them the time to safely stop their current action. Currently I’m manually checking if there is a player, then sending a mine say Reboot in 30 seconds then wait 30 seconds and do the reboot. I know it can be weird to wait, so it can be optional.

While writing all this, I realized that I can run a custom script next to msh rather than from msh:

#!/bin/bash

# some magic to get PID and process state
mcpid="$(pgrep -nu minecraft java)"
mcstatus="$(ps -q "${mcpid}" -o state --no-headers 2>/dev/null)"

if [[ "$mcstatus" != "T" ]] # T = frozen, so no player
then
	echo "mine say Stopping the server in 30 seconds" > /run/minecraft-server.stdin # it’s the standard input, via a socket
	sleep 30
fi

echo "msh exit" > /run/minecraft-server.stdin

and I’m saying to my system (SystemD on Linux) to run this script instead of sending SIGTERM signal to msh.

So on my side, everything is ok with this workaround (well, a way to prevent new players from login can be great).

@gekigek99
Copy link
Member

Sounds reasonable, I can't give you a definitive opinion but it's a nice idea.

But if i ever implement it, it will be done after 2.5.0 (which is almost ready).

@gekigek99 gekigek99 added enhancement New feature or request request User's suggested enhancement labels Jan 26, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request request User's suggested enhancement
Projects
None yet
Development

No branches or pull requests

2 participants