2018-05-23 13:03:19 -07:00
|
|
|
#!/bin/bash
|
2018-08-27 09:13:53 -07:00
|
|
|
#
|
|
|
|
# Starts a leader node
|
|
|
|
#
|
2018-06-23 11:52:12 -07:00
|
|
|
|
2018-06-24 10:10:55 -07:00
|
|
|
here=$(dirname "$0")
|
|
|
|
# shellcheck source=multinode-demo/common.sh
|
|
|
|
source "$here"/common.sh
|
2018-06-22 18:18:09 -07:00
|
|
|
|
2018-08-27 10:23:22 -07:00
|
|
|
# shellcheck source=scripts/oom-score-adj.sh
|
|
|
|
source "$here"/../scripts/oom-score-adj.sh
|
|
|
|
|
2018-06-24 10:10:55 -07:00
|
|
|
if [[ -d "$SNAP" ]]; then
|
|
|
|
# Exit if mode is not yet configured
|
|
|
|
# (typically the case after the Snap is first installed)
|
|
|
|
[[ -n "$(snapctl get mode)" ]] || exit 0
|
|
|
|
fi
|
2018-06-22 18:18:09 -07:00
|
|
|
|
2018-06-24 10:10:55 -07:00
|
|
|
[[ -f "$SOLANA_CONFIG_DIR"/leader.json ]] || {
|
2018-07-02 08:08:14 -07:00
|
|
|
echo "$SOLANA_CONFIG_DIR/leader.json not found, create it by running:"
|
|
|
|
echo
|
2018-07-30 15:10:42 -07:00
|
|
|
echo " ${here}/setup.sh"
|
2018-06-22 18:18:09 -07:00
|
|
|
exit 1
|
|
|
|
}
|
2018-06-14 17:11:55 -07:00
|
|
|
|
2018-06-24 10:10:55 -07:00
|
|
|
if [[ -n "$SOLANA_CUDA" ]]; then
|
|
|
|
program="$solana_fullnode_cuda"
|
|
|
|
else
|
|
|
|
program="$solana_fullnode"
|
|
|
|
fi
|
2018-06-22 11:37:42 -07:00
|
|
|
|
2018-07-02 17:35:28 -07:00
|
|
|
tune_networking
|
|
|
|
|
2018-07-30 14:29:34 -07:00
|
|
|
trap 'kill "$pid" && wait "$pid"' INT TERM
|
2018-07-17 13:31:24 -07:00
|
|
|
$program \
|
2018-07-12 15:45:41 -07:00
|
|
|
--identity "$SOLANA_CONFIG_DIR"/leader.json \
|
2018-08-03 11:06:06 -07:00
|
|
|
--ledger "$SOLANA_CONFIG_DIR"/ledger \
|
2018-07-30 14:29:34 -07:00
|
|
|
> >($leader_logger) 2>&1 &
|
|
|
|
pid=$!
|
2018-08-07 10:23:38 -07:00
|
|
|
oom_score_adj "$pid" 1000
|
2018-07-30 14:29:34 -07:00
|
|
|
wait "$pid"
|