Add file-based queue shutdown

This commit is contained in:
rubenwardy 2020-04-30 18:08:01 +01:00
parent b790cc7576
commit c951aca91f

View file

@ -77,9 +77,29 @@ minetest.register_chatcommand("ctf_unqueue_restart", {
end end
}) })
local function file_exists(path)
local file = io.open(path, "r")
if file then
file:close()
return true
end
return false
end
ctf_match.register_on_new_match(function() ctf_match.register_on_new_match(function()
if restart_on_next_match then if restart_on_next_match then
minetest.chat_send_player(restart_on_next_match_by, "Shutting down now!") minetest.chat_send_player(restart_on_next_match_by, "Shutting down now!")
minetest.request_shutdown("Restarting server at operator request.", true) minetest.request_shutdown("Restarting server at operator request.", true)
return
end
local path = minetest.get_worldpath() .. "/queue_restart.txt"
if file_exists(path) then
assert(os.remove(path))
minetest.request_shutdown("Restarting server at operator request.", true)
return
end end
end) end)