fixed gcsafe error on createPidFile
This commit is contained in:
parent
1b89a835eb
commit
a526d01ab8
|
@ -6,7 +6,7 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
std/[os, exitprocs],
|
||||
std/os,
|
||||
beacon_chain/nimbus_binary_common,
|
||||
beacon_chain/spec/forks,
|
||||
beacon_chain/[beacon_chain_db, trusted_node_sync],
|
||||
|
@ -22,22 +22,11 @@ export nimbus_configs
|
|||
logScope:
|
||||
topics = "Consensus layer"
|
||||
|
||||
## Copy paste from nimbus_beacon_node.nim Copied due to the fact that nimbus_beacon_node
|
||||
## contains the programMain.
|
||||
## following procedures are copies from nimbus_beacon_node.nim.
|
||||
## TODO: extract from that file into a common file
|
||||
var gPidFile: string
|
||||
|
||||
#TODO: Investigate why the commented code triggers GC violation
|
||||
proc createPidFile(filename: string) {.raises: [IOError].} =
|
||||
# writeFile filename, $os.getCurrentProcessId()
|
||||
writeFile filename, "222"
|
||||
# gPidFile = filename
|
||||
# addExitProc proc() {.noconv.} =
|
||||
# ## TODO: changed from original file, fixes dprecation warning
|
||||
# discard io2.removeFile(gPidFile)
|
||||
|
||||
## runs beacon node
|
||||
## adpated from nimbus-eth2
|
||||
## adapted from nimbus-eth2
|
||||
proc doRunBeaconNode(
|
||||
config: var BeaconNodeConf, rng: ref HmacDrbgContext
|
||||
) {.raises: [CatchableError].} =
|
||||
|
@ -59,8 +48,6 @@ proc doRunBeaconNode(
|
|||
ignoreDeprecatedOption validatorMonitorTotals
|
||||
ignoreDeprecatedOption web3ForcePolling
|
||||
|
||||
createPidFile(config.dataDir.string / "beacon_node.pid")
|
||||
|
||||
config.createDumpDirs()
|
||||
|
||||
#TODO: We might need to split this on the same file
|
||||
|
@ -146,6 +133,7 @@ proc doRunTrustedNodeSync(
|
|||
proc consensusWrapper*(parameters: TaskParameters) {.raises: [CatchableError].} =
|
||||
let rng = HmacDrbgContext.new()
|
||||
var config = parameters.beaconNodeConfigs
|
||||
|
||||
try:
|
||||
doRunBeaconNode(config, rng)
|
||||
except CatchableError as e:
|
||||
|
|
|
@ -6,8 +6,9 @@
|
|||
# at your option. This file may not be copied, modified, or distributed except according to those terms.
|
||||
|
||||
import
|
||||
std/[atomics, os],
|
||||
std/[atomics, os, exitprocs],
|
||||
chronicles,
|
||||
stew/io2,
|
||||
consensus/consensus_wrapper,
|
||||
execution/execution_wrapper,
|
||||
beacon_chain/[conf, conf_common],
|
||||
|
@ -61,6 +62,16 @@ proc joinTasks(tasks: var NimbusTasks) =
|
|||
|
||||
info "\tAll tasks finished"
|
||||
|
||||
#TODO: Investigate if this is really needed? and for what purpose?
|
||||
var gPidFile: string
|
||||
proc createPidFile(filename: string) {.raises: [IOError].} =
|
||||
writeFile filename, $os.getCurrentProcessId()
|
||||
gPidFile = filename
|
||||
addExitProc (
|
||||
proc() =
|
||||
discard io2.removeFile(filename)
|
||||
)
|
||||
|
||||
# ----
|
||||
|
||||
# ------------------------------------------------------------------------------
|
||||
|
@ -88,7 +99,6 @@ proc addNewTask*(
|
|||
|
||||
if currentIndex < 0:
|
||||
raise newException(NimbusTasksError, "No free slots on Nimbus Tasks")
|
||||
|
||||
createThread(tasks.taskList[currentIndex].threadHandler, taskHandler, parameters)
|
||||
info "Created task:", task = tasks.taskList[currentIndex].name
|
||||
|
||||
|
@ -109,7 +119,7 @@ proc monitor*(tasksList: var NimbusTasks, config: NimbusConfig) =
|
|||
## create running workers
|
||||
proc startTasks*(
|
||||
tasksList: var NimbusTasks, configs: NimbusConfig, beaconConfigs: var BeaconNodeConf
|
||||
) =
|
||||
) {.raises: [CatchableError].} =
|
||||
let
|
||||
|
||||
# TODO: extract configs for each task from NimbusConfig
|
||||
|
@ -174,6 +184,6 @@ when isMainModule:
|
|||
quit(0)
|
||||
|
||||
setControlCHook(controlCHandler)
|
||||
|
||||
createPidFile(beaconNodeConfig.databaseDir.string / "unified.pid")
|
||||
#start monitoring
|
||||
tasksList.monitor(nimbusConfigs)
|
||||
|
|
Loading…
Reference in New Issue