Merge branch 'nim-1.2'
This commit is contained in:
commit
71e9313e5f
|
@ -32,28 +32,15 @@ type
|
|||
NimbusState = enum
|
||||
Starting, Running, Stopping, Stopped
|
||||
|
||||
NimbusObject = ref object
|
||||
NimbusNode = ref object
|
||||
rpcServer*: RpcHttpServer
|
||||
ethNode*: EthereumNode
|
||||
state*: NimbusState
|
||||
|
||||
var nimbus: NimbusObject
|
||||
|
||||
proc start() =
|
||||
proc start(nimbus: NimbusNode) =
|
||||
var conf = getConfiguration()
|
||||
|
||||
nimbus = NimbusObject()
|
||||
nimbus.state = Starting
|
||||
|
||||
## Ctrl+C handling
|
||||
proc controlCHandler() {.noconv.} =
|
||||
when defined(windows):
|
||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||
setupForeignThreadGc()
|
||||
nimbus.state = Stopping
|
||||
echo "\nCtrl+C pressed. Waiting for a graceful shutdown."
|
||||
setControlCHook(controlCHandler)
|
||||
|
||||
## logging
|
||||
setLogLevel(conf.debug.logLevel)
|
||||
if len(conf.debug.logFile) != 0:
|
||||
|
@ -169,13 +156,13 @@ proc start() =
|
|||
# it might have been set to "Stopping" with Ctrl+C
|
||||
nimbus.state = Running
|
||||
|
||||
proc stop*() {.async.} =
|
||||
proc stop*(nimbus: NimbusNode) {.async, gcsafe.} =
|
||||
trace "Graceful shutdown"
|
||||
var conf = getConfiguration()
|
||||
if RpcFlags.Enabled in conf.rpc.flags:
|
||||
nimbus.rpcServer.stop()
|
||||
|
||||
proc process*() =
|
||||
proc process*(nimbus: NimbusNode) =
|
||||
if nimbus.state == Running:
|
||||
# Main loop
|
||||
while nimbus.state == Running:
|
||||
|
@ -185,9 +172,20 @@ proc process*() =
|
|||
debug "Exception in poll()", exc = e.name, err = e.msg
|
||||
|
||||
# Stop loop
|
||||
waitFor stop()
|
||||
waitFor nimbus.stop()
|
||||
|
||||
when isMainModule:
|
||||
var nimbus = NimbusNode()
|
||||
|
||||
## Ctrl+C handling
|
||||
proc controlCHandler() {.noconv.} =
|
||||
when defined(windows):
|
||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||
setupForeignThreadGc()
|
||||
nimbus.state = Stopping
|
||||
echo "\nCtrl+C pressed. Waiting for a graceful shutdown."
|
||||
setControlCHook(controlCHandler)
|
||||
|
||||
var message: string
|
||||
|
||||
## Print Nimbus header
|
||||
|
@ -205,6 +203,6 @@ when isMainModule:
|
|||
echo message
|
||||
quit(QuitSuccess)
|
||||
|
||||
start()
|
||||
process()
|
||||
nimbus.start()
|
||||
nimbus.process()
|
||||
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit 31ec33cf8e511fecd2cab6f57ffdfa81ca5ce9bd
|
||||
Subproject commit 0b1a9969be1a28e58bb50500ecddcb353c9547f0
|
|
@ -1 +1 @@
|
|||
Subproject commit 81aebe6a8955b9c6c598aaf36d2c3ff8edc0e5fa
|
||||
Subproject commit fb8af46311965fd076412e6e071dda571d282024
|
|
@ -1 +1 @@
|
|||
Subproject commit c39c0696806a0ef09bc90e477ea6b177d2824699
|
||||
Subproject commit 3d745a4b0c99b90edffa3fdcddf40783c7776c6b
|
|
@ -1 +1 @@
|
|||
Subproject commit 7a607bfd3d83be86f153517636370b76f3d7cf25
|
||||
Subproject commit 6e5d570490989c753d4645ba9173ef9358d302bb
|
|
@ -1 +1 @@
|
|||
Subproject commit 0b110f3287f26e03f5e7ac4c9e7f0103456895c0
|
||||
Subproject commit 3f1d6e2922e491bb883d7a8a19053dfef9ef6ea5
|
|
@ -1 +1 @@
|
|||
Subproject commit e7a34b74f298eaabd7bdbe2f080bf9747ed6bfd9
|
||||
Subproject commit 8a3cf6778d483a9d701534dfc2f14f3a4dfc4ab8
|
|
@ -1 +1 @@
|
|||
Subproject commit 21613254e8b2f95c9cb44fafb0ac1b10bbf2e046
|
||||
Subproject commit 33d70b9f378591e074838d6608a4468940137357
|
|
@ -1 +1 @@
|
|||
Subproject commit 09f6fd63556a22312af7c5a7e3fa105b26897316
|
||||
Subproject commit 5c0d0961114bcaaf3da52d5918bf0b85ef0e4ce9
|
|
@ -1 +1 @@
|
|||
Subproject commit 88b79e230005d8301c3ae950abdbf8ad55e37f19
|
||||
Subproject commit c108ba90e6b304515f08fdcff62f428f3f8fbe53
|
|
@ -1 +1 @@
|
|||
Subproject commit b641d2ad5b79baca6877329f75ba6266a5377c82
|
||||
Subproject commit da216986c635599dccffa2e71eabad03653e5aef
|
|
@ -1 +1 @@
|
|||
Subproject commit f2199d9285e5f626be0c30b3293b3d76b548ab54
|
||||
Subproject commit 5db86514a1185620a003d1e5ea1da4c0373c3b6e
|
|
@ -1 +1 @@
|
|||
Subproject commit 5b15d516265feac9470d78a88a0e1959ee22c21c
|
||||
Subproject commit bdc585bf9f3ad0acaad18c7d12deab172373b5f4
|
|
@ -1 +1 @@
|
|||
Subproject commit 85b2620a6e4c41eaa4caa378bd70902cff5a1c48
|
||||
Subproject commit 16b3cd84b6f8892cfd80c935caabdeb3390befaa
|
|
@ -1 +1 @@
|
|||
Subproject commit ae60eef4e8413e49fb0dbcae9a343fb479509fa0
|
||||
Subproject commit 0eab8cfeee55cfa3bb893ec31137d3c25b83a1ae
|
|
@ -1 +1 @@
|
|||
Subproject commit d954859d58e56292a3e42630c1ef1257eb26840b
|
||||
Subproject commit f08cbf9dc58fcda2377e5717aeeab584d42efee5
|
|
@ -1 +1 @@
|
|||
Subproject commit 9414202d53fac99a0b1af33acac816ff9236e6d0
|
||||
Subproject commit b06a5b6e32aa4d5abf9c1019ab6728fa8f360cc5
|
|
@ -1 +1 @@
|
|||
Subproject commit 30c7d332d8ebab28d3240018f48f145ff20af239
|
||||
Subproject commit cd7ff6eed2c802e81298325eff904af877907ec2
|
|
@ -1 +1 @@
|
|||
Subproject commit 2c4faa5372d2d8b0c2d16710fe5f93beab1c86af
|
||||
Subproject commit 0cce46e1260b053349d0d6f337f5d67a7bc14462
|
|
@ -1 +1 @@
|
|||
Subproject commit 71b41764aef41de04348c645b6e7d8bfe227fda2
|
||||
Subproject commit cd58cf69a0b883a4672cd3f79ee38ec0cf2c8c56
|
Loading…
Reference in New Issue