From cc88f9bcd60fd3f03c3b9e4747d2e2ef79fe8a48 Mon Sep 17 00:00:00 2001 From: Michael Vines Date: Tue, 22 Jan 2019 11:34:12 -0800 Subject: [PATCH] Add mechanism to determine when a node has finished booting --- fullnode/src/main.rs | 12 +++++++ multinode-demo/bootstrap-leader.sh | 25 +++++++++----- multinode-demo/fullnode.sh | 53 +++++++++++++++++------------- 3 files changed, 59 insertions(+), 31 deletions(-) diff --git a/fullnode/src/main.rs b/fullnode/src/main.rs index 3a555ffa40..fc9600ccf5 100644 --- a/fullnode/src/main.rs +++ b/fullnode/src/main.rs @@ -180,6 +180,13 @@ fn main() { .takes_value(true) .help("RPC port to use for this node"), ) + .arg( + Arg::with_name("init_complete_file") + .long("init-complete-file") + .value_name("FILE") + .takes_value(true) + .help("Create this file, if it doesn't already exist, once node initialization is complete"), + ) .get_matches(); let no_sigverify = matches.is_present("nosigverify"); @@ -210,6 +217,7 @@ fn main() { solana_netutil::find_available_port_in_range(FULLNODE_PORT_RANGE) .expect("unable to allocate rpc port") }; + let init_complete_file = matches.value_of("init_complete_file"); let keypair = Arc::new(keypair); let node = Node::new_with_external_ip(keypair.pubkey(), &gossip); @@ -258,6 +266,10 @@ fn main() { } } + if let Some(filename) = init_complete_file { + File::create(filename).unwrap_or_else(|_| panic!("Unable to create: {}", filename)); + } + info!("Node initialized"); loop { let status = fullnode.handle_role_transition(); match status { diff --git a/multinode-demo/bootstrap-leader.sh b/multinode-demo/bootstrap-leader.sh index 1a11f24632..f7135d3e0e 100755 --- a/multinode-demo/bootstrap-leader.sh +++ b/multinode-demo/bootstrap-leader.sh @@ -29,16 +29,22 @@ else program="$solana_fullnode" fi +maybe_init_complete_file= maybe_no_leader_rotation= -if [[ $1 = --no-leader-rotation ]]; then - maybe_no_leader_rotation="--no-leader-rotation" - shift -fi -if [[ -n $1 ]]; then - echo "Unknown argument: $1" - exit 1 -fi +while [[ -n $1 ]]; do + if [[ $1 = --init-complete-file ]]; then + maybe_init_complete_file="--init-complete-file $2" + shift 2 + elif [[ $1 = --no-leader-rotation ]]; then + maybe_no_leader_rotation="--no-leader-rotation" + shift + else + echo "Unknown argument: $1" + exit 1 + fi +done + if [[ -d $SNAP ]]; then if [[ $(snapctl get leader-rotation) = false ]]; then @@ -50,7 +56,10 @@ tune_system trap 'kill "$pid" && wait "$pid"' INT TERM $solana_ledger_tool --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger verify + +# shellcheck disable=SC2086 # Don't want to double quote maybe_init_complete_file $program \ + $maybe_init_complete_file \ $maybe_no_leader_rotation \ --identity "$SOLANA_CONFIG_DIR"/bootstrap-leader.json \ --ledger "$SOLANA_CONFIG_DIR"/bootstrap-leader-ledger \ diff --git a/multinode-demo/fullnode.sh b/multinode-demo/fullnode.sh index e26326bec0..d9618411b5 100755 --- a/multinode-demo/fullnode.sh +++ b/multinode-demo/fullnode.sh @@ -21,7 +21,7 @@ usage() { echo fi cat <