mirror of
https://github.com/MikaylaFischler/cc-mek-scada.git
synced 2024-08-30 18:22:34 +00:00
#124 debug stack trace on error
This commit is contained in:
parent
e679b5a25a
commit
9761228b8e
3
.vscode/settings.json
vendored
3
.vscode/settings.json
vendored
@ -13,6 +13,7 @@
|
||||
"window",
|
||||
"read",
|
||||
"periphemu",
|
||||
"mekanismEnergyHelper"
|
||||
"mekanismEnergyHelper",
|
||||
"_HOST"
|
||||
]
|
||||
}
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
require("/initenv").init_env()
|
||||
|
||||
local crash = require("scada-common.crash")
|
||||
local log = require("scada-common.log")
|
||||
local ppm = require("scada-common.ppm")
|
||||
local tcallbackdsp = require("scada-common.tcallbackdsp")
|
||||
@ -16,7 +17,7 @@ local config = require("coordinator.config")
|
||||
local coordinator = require("coordinator.coordinator")
|
||||
local renderer = require("coordinator.renderer")
|
||||
|
||||
local COORDINATOR_VERSION = "alpha-v0.6.11"
|
||||
local COORDINATOR_VERSION = "alpha-v0.6.12"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
@ -57,6 +58,13 @@ log.info("BOOTING coordinator.startup " .. COORDINATOR_VERSION)
|
||||
log.info("========================================")
|
||||
println(">> SCADA Coordinator " .. COORDINATOR_VERSION .. " <<")
|
||||
|
||||
crash.set_env("coordinator", COORDINATOR_VERSION)
|
||||
|
||||
----------------------------------------
|
||||
-- main application
|
||||
----------------------------------------
|
||||
|
||||
local function main()
|
||||
----------------------------------------
|
||||
-- system startup
|
||||
----------------------------------------
|
||||
@ -316,3 +324,6 @@ log_sys("system shutdown")
|
||||
|
||||
println_ts("exited")
|
||||
log.info("exited")
|
||||
end
|
||||
|
||||
if not xpcall(main, crash.handler) then crash.exit() end
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
require("/initenv").init_env()
|
||||
|
||||
local crash = require("scada-common.crash")
|
||||
local log = require("scada-common.log")
|
||||
local mqueue = require("scada-common.mqueue")
|
||||
local ppm = require("scada-common.ppm")
|
||||
@ -13,7 +14,7 @@ local config = require("reactor-plc.config")
|
||||
local plc = require("reactor-plc.plc")
|
||||
local threads = require("reactor-plc.threads")
|
||||
|
||||
local R_PLC_VERSION = "beta-v0.9.6"
|
||||
local R_PLC_VERSION = "beta-v0.9.7"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
@ -45,6 +46,13 @@ log.info("BOOTING reactor-plc.startup " .. R_PLC_VERSION)
|
||||
log.info("========================================")
|
||||
println(">> Reactor PLC " .. R_PLC_VERSION .. " <<")
|
||||
|
||||
crash.set_env("plc", R_PLC_VERSION)
|
||||
|
||||
----------------------------------------
|
||||
-- main application
|
||||
----------------------------------------
|
||||
|
||||
local function main()
|
||||
----------------------------------------
|
||||
-- startup
|
||||
----------------------------------------
|
||||
@ -208,3 +216,6 @@ end
|
||||
|
||||
println_ts("exited")
|
||||
log.info("exited")
|
||||
end
|
||||
|
||||
if not xpcall(main, crash.handler) then crash.exit() end
|
||||
|
@ -4,6 +4,7 @@
|
||||
|
||||
require("/initenv").init_env()
|
||||
|
||||
local crash = require("scada-common.crash")
|
||||
local log = require("scada-common.log")
|
||||
local mqueue = require("scada-common.mqueue")
|
||||
local ppm = require("scada-common.ppm")
|
||||
@ -24,7 +25,7 @@ local sna_rtu = require("rtu.dev.sna_rtu")
|
||||
local sps_rtu = require("rtu.dev.sps_rtu")
|
||||
local turbinev_rtu = require("rtu.dev.turbinev_rtu")
|
||||
|
||||
local RTU_VERSION = "beta-v0.9.3"
|
||||
local RTU_VERSION = "beta-v0.9.4"
|
||||
|
||||
local rtu_t = types.rtu_t
|
||||
|
||||
@ -58,6 +59,13 @@ log.info("BOOTING rtu.startup " .. RTU_VERSION)
|
||||
log.info("========================================")
|
||||
println(">> RTU GATEWAY " .. RTU_VERSION .. " <<")
|
||||
|
||||
crash.set_env("rtu", RTU_VERSION)
|
||||
|
||||
----------------------------------------
|
||||
-- main application
|
||||
----------------------------------------
|
||||
|
||||
local function main()
|
||||
----------------------------------------
|
||||
-- startup
|
||||
----------------------------------------
|
||||
@ -396,3 +404,6 @@ end
|
||||
|
||||
println_ts("exited")
|
||||
log.info("exited")
|
||||
end
|
||||
|
||||
if not xpcall(main, crash.handler) then crash.exit() end
|
||||
|
46
scada-common/crash.lua
Normal file
46
scada-common/crash.lua
Normal file
@ -0,0 +1,46 @@
|
||||
--
|
||||
-- Crash Handler
|
||||
--
|
||||
|
||||
local comms = require("scada-common.comms")
|
||||
local log = require("scada-common.log")
|
||||
local util = require("scada-common.util")
|
||||
|
||||
local crash = {}
|
||||
|
||||
local app = "unknown"
|
||||
local ver = "v0.0.0"
|
||||
local err = ""
|
||||
|
||||
-- set crash environment
|
||||
---@param application string app name
|
||||
---@param version string version
|
||||
function crash.set_env(application, version)
|
||||
app = application
|
||||
ver = version
|
||||
end
|
||||
|
||||
-- handle a crash error
|
||||
---@param error string error message
|
||||
function crash.handler(error)
|
||||
err = error
|
||||
log.info("=====> FATAL SOFTWARE FAULT <=====")
|
||||
log.fatal(error)
|
||||
log.info("----------------------------------")
|
||||
log.info(util.c("RUNTIME: ", _HOST))
|
||||
log.info(util.c("LUA VERSION: ", _VERSION))
|
||||
log.info(util.c("APPLICATION: ", app))
|
||||
log.info(util.c("FIRMWARE VERSION: ", ver))
|
||||
log.info(util.c("COMMS VERSION: ", comms.version))
|
||||
log.info("----------------------------------")
|
||||
log.info(debug.traceback("--- begin debug trace ---", 1))
|
||||
log.info("--- end debug trace ---")
|
||||
end
|
||||
|
||||
-- final error print on failed xpcall, app exits here
|
||||
function crash.exit()
|
||||
util.println("fatal error occured in main application:")
|
||||
error(err, 0)
|
||||
end
|
||||
|
||||
return crash
|
@ -4,6 +4,7 @@
|
||||
|
||||
require("/initenv").init_env()
|
||||
|
||||
local crash = require("scada-common.crash")
|
||||
local log = require("scada-common.log")
|
||||
local ppm = require("scada-common.ppm")
|
||||
local util = require("scada-common.util")
|
||||
@ -13,7 +14,7 @@ local svsessions = require("supervisor.session.svsessions")
|
||||
local config = require("supervisor.config")
|
||||
local supervisor = require("supervisor.supervisor")
|
||||
|
||||
local SUPERVISOR_VERSION = "beta-v0.7.5"
|
||||
local SUPERVISOR_VERSION = "beta-v0.7.6"
|
||||
|
||||
local print = util.print
|
||||
local println = util.println
|
||||
@ -57,6 +58,13 @@ log.info("BOOTING supervisor.startup " .. SUPERVISOR_VERSION)
|
||||
log.info("========================================")
|
||||
println(">> SCADA Supervisor " .. SUPERVISOR_VERSION .. " <<")
|
||||
|
||||
crash.set_env("supervisor", SUPERVISOR_VERSION)
|
||||
|
||||
----------------------------------------
|
||||
-- main application
|
||||
----------------------------------------
|
||||
|
||||
local function main()
|
||||
----------------------------------------
|
||||
-- startup
|
||||
----------------------------------------
|
||||
@ -149,3 +157,6 @@ end
|
||||
|
||||
println_ts("exited")
|
||||
log.info("exited")
|
||||
end
|
||||
|
||||
if not xpcall(main, crash.handler) then crash.exit() end
|
||||
|
Loading…
Reference in New Issue
Block a user