What I want to achieve:
A more graceful server shutdown procedure, meaning all resources have time to save, log, update and do other miscellaneous tasks before the server is allowed to shut down. I don’t want to change anything on the clients’ side.
What I’ve tried so far:
I have created a custom exit command which executes the quit command once all resources are ready.
Simple example
RegisterCommand("exit", function(source, args, rawCommand)
local _source = source
if _source == 0 then
--[[
Functions to update the server status,
log the time and maybe args too,
give players a 15-30s warning, etc.
]]
ExecuteCommand("quit")
end
end)
Note: Requires add_ace resource.name command.quit allow
After that I tried adding an ace to system.console, denying the quit permission in case I enter quit out of muscle memory, hoping that the resource would still be allowed to execute the command, but that didn’t work out.
I also tried using the onResourceStop and onServerResourceStop events, but those only report after a resource has already stopped, unless I missed something.
My questions:
- Is there a better solution, eg. executing
quitand the server will wait for everything to finish? - If the above isn’t possible, maybe blocking the
quitcommand from being executed in the console window so I, and perhaps others, can’t accidentally use the wrong procedure due to muscle memory? - Or did I completely miss an event or a function that could help me out here?
Little side-note: I’m not using txAdmin, meaning that I won’t have to modify it.
Thanks in advance for any help and tips!