mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-15 21:47:21 +00:00
setting control-c handler
This commit is contained in:
parent
ecc8c51bd4
commit
9478abafcd
@ -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)
|
Loading…
x
Reference in New Issue
Block a user