diff --git a/nimbus_unified/nimbus_unified.cfg b/nimbus_unified/nimbus_unified.cfg new file mode 100644 index 000000000..a7f0bad4e --- /dev/null +++ b/nimbus_unified/nimbus_unified.cfg @@ -0,0 +1,14 @@ +# nimbus_unified +# Copyright (c) 2024 Status Research & Development GmbH +# Licensed and distributed under either of +# * MIT license (license terms in the root directory or at https://opensource.org/licenses/MIT). +# * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). +# at your option. This file may not be copied, modified, or distributed except according to those terms. + +-d:"chronicles_sinks=textlines[dynamic],json[dynamic]" +-d:"chronicles_runtime_filtering=on" +-d:"chronicles_disable_thread_id" + +@if release: + -d:"chronicles_line_numbers:0" +@end \ No newline at end of file diff --git a/nimbus_unified/nimbus_unified.nim b/nimbus_unified/nimbus_unified.nim index 22698dc21..27ab23205 100644 --- a/nimbus_unified/nimbus_unified.nim +++ b/nimbus_unified/nimbus_unified.nim @@ -5,7 +5,7 @@ # * Apache v2 license (license terms in the root directory or at https://www.apache.org/licenses/LICENSE-2.0). # at your option. This file may not be copied, modified, or distributed except according to those terms. -import std/[atomics, os, tables], beacon_chain/nimbus_binary_common +import std/[atomics, os, tables], chronicles, beacon_chain/nimbus_binary_common ## Exceptions type NimbusTasksError* = object of CatchableError @@ -41,29 +41,33 @@ type NimbusTask* = ref object type NimbusTasks* = ref object taskList*: array[cNimbusMaxTasks, NimbusTask] +## log +logScope: + topics = "Task manager" + # ------------------------------------------------------------------------------ # Private and helper functions # ------------------------------------------------------------------------------ ## Execution Layer handler proc executionLayerHandler(parameters: TaskParameters) {.thread.} = - echo "Started task:" + info "Started task:", task = parameters.name while true: sleep(3000) - echo "exec" + info "exec" if isShutDownRequired.load() == true: break - echo "\tExiting task" + info "\tExiting task;", task = parameters.name ## Consensus Layer handler proc consensusLayerHandler(parameters: TaskParameters) {.thread.} = - echo "Started task:" + info "Started task:", task = parameters.name while true: sleep(3000) - echo "exec" + info "exec" if isShutDownRequired.load() == true: break - echo "\tExiting task" + info "\tExiting task:", task = parameters.name ## Waits for tasks to finish proc joinTasks(tasks: var NimbusTasks) = @@ -71,7 +75,7 @@ proc joinTasks(tasks: var NimbusTasks) = if not tasks.taskList[i].isNil: joinThread(tasks.taskList[i].threadHandler) - echo "\tAll tasks finished" + info "\tAll tasks finished" # ---- @@ -103,14 +107,14 @@ proc addNewTask*( raise newException(NimbusTasksError, "No free slots on Nimbus Tasks") createThread(tasks.taskList[currentIndex].threadHandler, taskHandler, parameters) - echo "Created task:" + info "Created task:", task = tasks.taskList[currentIndex].name ## Task monitoring proc monitor*(tasksList: var NimbusTasks, config: NimbusConfig) = - echo "monitoring tasks" + info "monitoring tasks" while true: - echo "nothing new" + info "nothing new" sleep(5000) ## create running workers @@ -131,7 +135,7 @@ proc startTasks*(tasksList: var NimbusTasks, configs: NimbusConfig) = ) when isMainModule: - echo "Starting Nimbus" + info "Starting Nimbus" ## TODO ## - make banner and config ## - file limits @@ -143,7 +147,6 @@ when isMainModule: let nimbusConfigs = NimbusConfig() var tasksList: NimbusTasks = NimbusTasks.new - ## next code snippet requires a conf.nim file (eg: beacon_lc_bridge_conf.nim) # var config = makeBannerAndConfig("Nimbus client ", NimbusConfig) # setupLogging(config.logLevel, config.logStdout, config.logFile) @@ -159,15 +162,15 @@ when isMainModule: except NimbusTasksError as exc: raiseAssert exc.msg # shouldn't happen - echo "\nCtrl+C pressed. Shutting down working tasks" + notice "\nCtrl+C pressed. Shutting down working tasks" isShutDownRequired.store(true) tasksList.joinTasks() - echo "Shutting down now" + notice "Shutting down now" quit(0) setControlCHook(controlCHandler) while true: - echo "looping" - sleep(2000) \ No newline at end of file + info "looping" + sleep(2000)