setting control-c handler

This commit is contained in:
Pedro Miranda 2024-10-18 19:14:35 +01:00
parent ecc8c51bd4
commit 9478abafcd

View File

@ -5,5 +5,36 @@
# * 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 os
when isMainModule:
echo "hello Nimbus"
echo "Starting Nimbus"
## TODO
## - make banner and config
## - file limits
## - check if we have permissions to create data folder if needed
## - setup logging
## this 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)
## Graceful shutdown by handling of Ctrl+C signal
proc controlCHandler() {.noconv.} =
when defined(windows):
# workaround for https://github.com/nim-lang/Nim/issues/4057
try:
setupForeignThreadGc()
except NimbusTasksError as exc:
raiseAssert exc.msg # shouldn't happen
echo "\nCtrl+C pressed. Shutting down working tasks"
echo "Shutting down now"
quit(0)
setControlCHook(controlCHandler)
while true:
echo "looping"
sleep(2000)