Page 1 of 1

[Mod] Simple Shutdown helper [v1.5] [timer_shutdown]

PostPosted: Thu Aug 01, 2013 18:17
by fairiestoy
Hello there,

since it could be some kind of annoying if the server just suddenly shuts down by operator request, i made this little tool. This way, server admins and/or moderators can shut down the server with a reason which is printed to all users. And it also only shuts down after a given time.

License: - No license -
Version: 1.5
Features:
> Countdown
It counts the seconds from 5 down to 0
( up to now, its also counting the *.5 values too, will be fixed soon )
> User privs
To use this command, one has to have the privilege 'q_shutdown'
This might be useful if you grant this to a trustful moderator and
have a automatic restart script running for minetest (may be added into
this mod also, but its only a idea for now), the moderator will be capable
of restarting the server with this request.
> (Basic) Logging
This mod logs the reason and the name when this command has been called.
Should a user abuse this feature, the server admin could easily revoke the priv
> Global Reason message
Up to now, it only supports one word as reason (example "Restart"). It will support
a string later (planned for v1.6). It sends a global chat message to all players with the
time when it will shut down, and the reason
> Time based shutdown
The <time> parameter takes the seconds when the server should shut down
> Remote Control shutdown
(Up to now insecure, please wait for future release) It currently works with a local file.
If a user called the /remote_control on command, it will check a file every 200 server
steps ( i took this value to maybe reduce performance impact due to io operations )
-- since v1.5
> Performance shutdown
Implemented a function, which checks if the server globalstep delay is to huge. If the
expected steps according to the server settings are about 75% higher than the steps that
Should have kicked in, the server will shut down.
Warning!This is only usable if you have a automatic restart script for your server.
> Empty user list shutdown
Shuts the server down, if the user list is empty

I checked the forum search, but i found nothing similiar. If there is already something like this, just let me know :3

Ver 1.5
Download (Github)
Source:
fairiestoy/timer_shutdown @Github

Greetings

PostPosted: Thu Aug 01, 2013 18:25
by Sokomine
Good idea, even though most server admins seem to do that manually already.

PostPosted: Thu Aug 01, 2013 19:16
by VanessaE
A feature I'd love to see is one where you can set a one-time, future shutdown to happen when the last user signs off, which would work best when the server is run with some kind of auto-restart script (I think most of us do that).

That way, when you see some significant update to the Minetest engine or to one or more of your mods, you can download and update them, and then schedule the server to shut down exactly once (and presumably auto-restart) as soon as there's no one left online.

This would allow the admin to set up some updates and just walk away to run errands or whatever, without having to babysit the server waiting for an opportunity to restart manually, or interrupting someone's play.

PostPosted: Thu Aug 01, 2013 19:52
by BrandonReese
VanessaE wrote:A feature I'd love to see is one where you can set a one-time, future shutdown to happen when the last user signs off, which would work best when the server is run with some kind of auto-restart script (I think most of us do that).

That way, when you see some significant update to the Minetest engine or to one or more of your mods, you can download and update them, and then schedule the server to shut down exactly once (and presumably auto-restart) as soon as there's no one left online.

This would allow the admin to set up some updates and just walk away to run errands or whatever, without having to babysit the server waiting for an opportunity to restart manually, or interrupting someone's play.


I've had this idea in my head for a few weeks and haven't had time to work on it. I bet fairiestoy could update his mod to make it do this.

PostPosted: Thu Aug 01, 2013 20:23
by fairiestoy
VanessaE wrote:A feature I'd love to see is one where you can set a one-time, future shutdown to happen when the last user signs off, which would work best when the server is run with some kind of auto-restart script (I think most of us do that).


Already added. If someone could test it, i would appreciate it. I made a local test with two clients connecting. The admin client called the command and left. After the guest client disconnected, the server shutted down.

Edit:

Usage:
Call ingame /shutdown_if_empty <qots_id> where the id is any string (unused now, but may be relevant if one decides to make this avaible to mods for tracking abuse).
Up to now, this works only for the ingame call. The RC method will be implemented later since i have to think about a relative function for calling RC methods (now its fixed for one specific purpose).

PostPosted: Fri Aug 02, 2013 09:35
by VanessaE
Also, as an aside, "no license" is not valid. If you don't have a specific license in mind or didn't think you needed one, you probably meant to release to Public Domain. In that case, use WTFPL or CC0 as your license. Maybe BSD might be suitable also, if you want to retain at least some semblance of authorship.

http://en.wikipedia.org/wiki/WTFPL
http://creativecommons.org/choose/zero/
http://en.wikipedia.org/wiki/BSD_licenses

PostPosted: Fri Aug 02, 2013 12:38
by Evergreen
Very useful for servers. Also, "-no license- is not applicable. I think WTFPL would suit your needs if you don't want it to have a license.

PostPosted: Fri Aug 02, 2013 14:42
by mauvebic
VanessaE wrote:Also, as an aside, "no license" is not valid.


Not to get technical, but no license is basic copyright. I think you might have meant he should choose some license if he wants to get this past /general.

fairiestoy, could you could do a feature that auto-restarts on crash?

PostPosted: Fri Aug 02, 2013 16:46
by fairiestoy
mauvebic wrote:I think you might have meant he should choose some license if he wants to get this past /general.

fairiestoy, could you could do a feature that auto-restarts on crash?

Point 1)
So a given license is only important to get this topic moved to Mod Releases? However, i will use the WTFPL since i like the phrase 'Do what the fuck you want to ...' taking effect on source code.
Point 2)
Have you something special in mind? Since there are some scripts out there that may be much more tested instead of re-inventing the weel. If you run Linux, this could be one example:
Your phone or window isn't wide enough to display the code box. If it's a phone, try rotating it to landscape mode.
Code: Select all
while true;do;minetestserver <commandline parameters>;sleep 1;done

The landrush server for example uses a similiar bash script afaik. If you are looking for something with some advanced features, I would like to give it a try.

PostPosted: Sat Aug 03, 2013 17:15
by fairiestoy
Testers wanted!
Since version 1.5, i made a routine that will check the server performance according to the globalsteps and will shut everything down if the expected globalsteps are about 75% higher than the realized globalsteps. But up to now, i was not capable of creating a situation to test this. If someone knows a way, or is capable of creating a situation with a laggy server: Could you please give feedback if everything works like it should?

In game command: /activate_performance_shutdown

PostPosted: Sat Aug 03, 2013 17:40
by BrandonReese
Just installed it to test your active performance shutdown. It would be nice if you sent a chat message after each command just so the user knows the command was received and executed.

PostPosted: Sat Aug 03, 2013 22:38
by fairiestoy
BrandonReese wrote:Just installed it to test your active performance shutdown. It would be nice if you sent a chat message after each command just so the user knows the command was received and executed.

Thanks for the test and the clue with the output on activation. I already updated it, and added a little thing to give the server 5 chances before shutting it down because of bad performance. I did this, because performance could get sometimes a bit low even on a local running server when joining. Maybe this keeps the server from being shut down after restart.

PostPosted: Sun Aug 04, 2013 18:24
by fairiestoy
* Updatet
I make the performance shutdown more persistent. Once you activated it, it will be active for 3 more restarts.
As long as the minetest.conf is not changing