diff options
| author | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2026-06-03 22:31:42 +0200 |
|---|---|---|
| committer | Lizzy Fleckenstein <lizzy@vlhl.dev> | 2026-06-03 23:30:17 +0200 |
| commit | 341af788ffb60b1066f7735c10a2ef8480ec0aa9 (patch) | |
| tree | b1acbfe48184a263098e6146922730dd7ece8808 /standalone_server.lua | |
| parent | a42c94e103ecf7cb365a8888c3f5afc785def284 (diff) | |
| download | r6p-main.tar.xz | |
Diffstat (limited to 'standalone_server.lua')
| -rwxr-xr-x | standalone_server.lua | 47 |
1 files changed, 36 insertions, 11 deletions
diff --git a/standalone_server.lua b/standalone_server.lua index a1dd571..9221984 100755 --- a/standalone_server.lua +++ b/standalone_server.lua @@ -1,20 +1,45 @@ #!/usr/bin/env lua5.1 local server = require("server") -local srv = server.create() -local started = false +local srv, err = server.create(assert(arg[1])) +if err then + if err == "save_corrupted" then + print("[standalone_server] savefile corrupted (try restoring backup?)") + elseif err == "save_write_failed" then + print("[standalone_server] failed to open savefile for writing") + else + print(err) + end + os.exit(1) +end -while true do - server.update(srv) - local status, invite = server.match_status(srv) +local function server_loop() + local started = false + while true do + server.update(srv) + local status, invite = server.match_status(srv) - if status == "fail" then - print("failed to register match (match server down?)") - break - elseif status == "active" and not started then - started = true - print("invite: " .. invite) + if status == "fail" then + print("[standalone_server] failed to register match (match server down?)") + return false + elseif status == "active" and not started then + started = true + print("[standalone_server] invite: " .. invite) + end end end +local _, success = xpcall(server_loop, function(err) + if err:find("interrupted!") then + return true + end + print(debug.traceback(err, 2)) + return false +end, srv) + +print("[standalone_server] shutting down") server.close(srv) + +if not success then + os.exit(1) +end |
