blob: 9221984ba8a23682dbf16089b27e5b25ade7d4ed (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
|
#!/usr/bin/env lua5.1
local server = require("server")
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
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("[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
|