-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.lua
executable file
·56 lines (46 loc) · 1.1 KB
/
main.lua
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
46
47
48
49
50
51
52
53
54
55
56
#!/usr/bin/env ./gh_wrapper
package.path = package.path .. ";library/?.lua;scripts/?.lua"
local ffi = require("ffi")
local gh = require("gh")
local json = require("json")
local decimal = require("decimal")
local executor = require("executor")
gh.cdef()
json.cdef()
decimal.cdef()
local grasshopper = ffi.load("grasshopper")
gh.set_clib(grasshopper)
json.set_clib(grasshopper)
decimal.set_clib(grasshopper)
gh.initialize()
require("test")
local sigint = false
local success, err = xpcall(executor.event_loop, function(e)
if e == executor.interrupts.terminate then
sigint = true
end
print(debug.traceback())
return e
end)
if success then
if err == executor.interrupts.terminate then
sigint = true
end
else
if err == executor.interrupts.terminate then
sigint = true
elseif err ~= executor.interrupts.restart then
local errstr = tostring(err)
if string.sub(errstr, #errstr - #"interrupted!" + 1, #errstr) == "interrupted!" then
gh.debug("got interrupt signal")
sigint = true
else
gh.error(errstr)
end
end
end
executor.clear_strategies()
gh.deinitialize()
if sigint then
os.exit(130)
end