mirror of
https://github.com/logos-storage/logos-storage-nim.git
synced 2026-01-08 00:13:08 +00:00
Prevent double start issue
This commit is contained in:
parent
1edb37c8f5
commit
5a78018b75
@ -57,6 +57,7 @@ type
|
|||||||
repoStore: RepoStore
|
repoStore: RepoStore
|
||||||
maintenance: BlockMaintainer
|
maintenance: BlockMaintainer
|
||||||
taskpool: Taskpool
|
taskpool: Taskpool
|
||||||
|
isStarted: bool
|
||||||
|
|
||||||
CodexPrivateKey* = libp2p.PrivateKey # alias
|
CodexPrivateKey* = libp2p.PrivateKey # alias
|
||||||
EthWallet = ethers.Wallet
|
EthWallet = ethers.Wallet
|
||||||
@ -168,6 +169,10 @@ proc bootstrapInteractions(s: CodexServer): Future[void] {.async.} =
|
|||||||
s.codexNode.contracts = (client, host, validator)
|
s.codexNode.contracts = (client, host, validator)
|
||||||
|
|
||||||
proc start*(s: CodexServer) {.async.} =
|
proc start*(s: CodexServer) {.async.} =
|
||||||
|
if s.isStarted:
|
||||||
|
warn "Codex server already started, skipping"
|
||||||
|
return
|
||||||
|
|
||||||
trace "Starting codex node", config = $s.config
|
trace "Starting codex node", config = $s.config
|
||||||
await s.repoStore.start()
|
await s.repoStore.start()
|
||||||
|
|
||||||
@ -188,7 +193,13 @@ proc start*(s: CodexServer) {.async.} =
|
|||||||
if s.restServer != nil:
|
if s.restServer != nil:
|
||||||
s.restServer.start()
|
s.restServer.start()
|
||||||
|
|
||||||
|
s.isStarted = true
|
||||||
|
|
||||||
proc stop*(s: CodexServer) {.async.} =
|
proc stop*(s: CodexServer) {.async.} =
|
||||||
|
if not s.isStarted:
|
||||||
|
warn "Codex is not started"
|
||||||
|
return
|
||||||
|
|
||||||
notice "Stopping codex node"
|
notice "Stopping codex node"
|
||||||
|
|
||||||
var futures =
|
var futures =
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user