Ctrl+C handling and:
- added a "quitProc" for shutting down the p2pd process, after seeing it survive an unhandled exception (this required a global var for the DaemonApi instance) - Makefile testnet0/1 targets now depend on the "p2pd" binary - prefixed the testnet command line in the build script message with "../../env.sh" so it can find the superproject's "p2pd"
This commit is contained in:
parent
7bc2b81e18
commit
2768a3e89e
5
Makefile
5
Makefile
|
@ -34,6 +34,9 @@ build:
|
|||
nat-libs: | deps
|
||||
+ $(MAKE) --silent -C ../../ nat-libs
|
||||
|
||||
p2pd: | deps
|
||||
+ $(MAKE) --silent -C ../../ vendor/go/bin/p2pd
|
||||
|
||||
# Windows 10 with WSL enabled, but no distro installed, fails if "../../nimble.sh" is executed directly
|
||||
# in a Makefile recipe but works when prefixing it with `bash`. No idea how the PATH is overridden.
|
||||
test: | build deps nat-libs
|
||||
|
@ -50,7 +53,7 @@ clean_eth2_network_simulation_files:
|
|||
eth2_network_simulation: | beacon_node validator_keygen clean_eth2_network_simulation_files
|
||||
SKIP_BUILDS=1 GIT_ROOT="$$PWD" BUILD_OUTPUTS_DIR="./build" tests/simulation/start.sh
|
||||
|
||||
testnet0 testnet1: | build deps nat-libs
|
||||
testnet0 testnet1: | build deps nat-libs p2pd
|
||||
../../env.sh scripts/build_testnet_node.sh $@
|
||||
|
||||
clean-testnet0:
|
||||
|
|
|
@ -723,6 +723,15 @@ when isMainModule:
|
|||
if config.logLevel != LogLevel.NONE:
|
||||
setLogLevel(config.logLevel)
|
||||
|
||||
## Ctrl+C handling
|
||||
proc controlCHandler() {.noconv.} =
|
||||
when defined(windows):
|
||||
# workaround for https://github.com/nim-lang/Nim/issues/4057
|
||||
setupForeignThreadGc()
|
||||
debug "Shutting down after having received SIGINT"
|
||||
quit(1)
|
||||
setControlCHook(controlCHandler)
|
||||
|
||||
case config.cmd
|
||||
of createTestnet:
|
||||
var deposits: seq[Deposit]
|
||||
|
|
|
@ -166,6 +166,8 @@ else:
|
|||
template tcpEndPoint(address, port): auto =
|
||||
MultiAddress.init(address, Protocol.IPPROTO_TCP, port)
|
||||
|
||||
var mainDaemon: DaemonAPI
|
||||
|
||||
proc createEth2Node*(conf: BeaconNodeConf): Future[Eth2Node] {.async.} =
|
||||
var
|
||||
(extIp, extTcpPort, extUdpPort) = setupNat(conf)
|
||||
|
@ -174,13 +176,18 @@ else:
|
|||
else: @[tcpEndPoint(extIp, extTcpPort)]
|
||||
keyFile = conf.ensureNetworkIdFile
|
||||
|
||||
info "Starting LibP2P deamon", hostAddress, announcedAddresses, keyFile
|
||||
let daemon = await newDaemonApi({PSGossipSub},
|
||||
id = keyFile,
|
||||
hostAddresses = @[hostAddress],
|
||||
announcedAddresses = announcedAddresses)
|
||||
info "Starting the LibP2P daemon", hostAddress, announcedAddresses, keyFile
|
||||
mainDaemon = await newDaemonApi({PSGossipSub},
|
||||
id = keyFile,
|
||||
hostAddresses = @[hostAddress],
|
||||
announcedAddresses = announcedAddresses)
|
||||
|
||||
return await Eth2Node.init(daemon)
|
||||
proc closeDaemon() {.noconv.} =
|
||||
info "Shutting down the LibP2P daemon"
|
||||
waitFor mainDaemon.close()
|
||||
addQuitProc(closeDaemon)
|
||||
|
||||
return await Eth2Node.init(mainDaemon)
|
||||
|
||||
proc getPersistenBootstrapAddr*(conf: BeaconNodeConf,
|
||||
ip: IpAddress, port: Port): BootstrapAddr =
|
||||
|
|
|
@ -27,7 +27,7 @@ fi
|
|||
echo
|
||||
echo "Done! You're now ready to connect to $NETWORK_NAME by running:"
|
||||
echo
|
||||
echo " $BEACON_NODE_BIN"
|
||||
echo " ../../env.sh $BEACON_NODE_BIN"
|
||||
echo
|
||||
echo "Database and configuration files will be placed in:"
|
||||
echo
|
||||
|
|
Loading…
Reference in New Issue