added monitoring skeleton

This commit is contained in:
Pedro Miranda 2024-10-19 02:44:53 +01:00
parent 53f4bbcac7
commit caec70c17f
1 changed files with 13 additions and 7 deletions

View File

@ -96,8 +96,14 @@ proc monitor*(tasksList: var NimbusTasks, config: NimbusConfig) =
info "monitoring tasks" info "monitoring tasks"
while true: while true:
info "nothing new" info "checking tasks ... "
sleep(5000)
# -check an atomic (to be created when needed) if it s required to shutdown
# this will atomic flag solves:
# - non responding thread
# - thread that required shutdown
sleep(cNimbusTaskTimeoutMs)
## create running workers ## create running workers
proc startTasks*(tasksList: var NimbusTasks, configs: NimbusConfig) = proc startTasks*(tasksList: var NimbusTasks, configs: NimbusConfig) =
@ -116,6 +122,8 @@ proc startTasks*(tasksList: var NimbusTasks, configs: NimbusConfig) =
"Consensus Layer", cNimbusTaskTimeoutMs, consensusLayerHandler, paramsConsensus "Consensus Layer", cNimbusTaskTimeoutMs, consensusLayerHandler, paramsConsensus
) )
# ------
when isMainModule: when isMainModule:
info "Starting Nimbus" info "Starting Nimbus"
## TODO ## TODO
@ -129,7 +137,7 @@ when isMainModule:
let nimbusConfigs = NimbusConfig() let nimbusConfigs = NimbusConfig()
var tasksList: NimbusTasks = NimbusTasks.new var tasksList: NimbusTasks = NimbusTasks.new
## next code snippet requires a conf.nim file (eg: beacon_lc_bridge_conf.nim) ## this code snippet requires a conf.nim file (eg: beacon_lc_bridge_conf.nim)
# var config = makeBannerAndConfig("Nimbus client ", NimbusConfig) # var config = makeBannerAndConfig("Nimbus client ", NimbusConfig)
# setupLogging(config.logLevel, config.logStdout, config.logFile) # setupLogging(config.logLevel, config.logStdout, config.logFile)
@ -150,9 +158,7 @@ when isMainModule:
tasksList.joinTasks() tasksList.joinTasks()
notice "Shutting down now" notice "Shutting down now"
quit(0) quit(0)
setControlCHook(controlCHandler) setControlCHook(controlCHandler)
while true: #start monitoring
info "looping" tasksList.monitor(nimbusConfigs)
sleep(2000)