Skip to content

Commit

Permalink
Make COSMOVISOR_ENABLED and START_CMD work as intended (take 2)
Browse files Browse the repository at this point in the history
Users generally want to:

1. Run the blockchain binary either as-is, -or- with snapshot.sh, -or- with
cosmovisor. These are controlled `SNAPSHOT_PATH`, and `COSMOVISOR_ENABLED`.

and then:

2. Be able to set the blockchain binary command to something else than the
default "start". This can be done with `START_CMD` - to amend/override that
command via environment variables without changes to deployment logic - e.g.
docker-compose yml (unlike with command line args to "docker run ...").

So change the logic to be: "use rule 1 above for prefix, then if args exists
then use them, else if `START_CMD` exists then use it, else use `start`". I
amended the PR accordingly.
  • Loading branch information
orenl-lava committed Jun 18, 2023
1 parent 21aba8a commit 6538e60
Showing 1 changed file with 8 additions and 6 deletions.
14 changes: 8 additions & 6 deletions run.sh
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@ export PROJECT_BIN="${PROJECT_BIN:-$PROJECT}"
export PROJECT_DIR="${PROJECT_DIR:-.$PROJECT_BIN}"
export CONFIG_DIR="${CONFIG_DIR:-config}"
if [ "$COSMOVISOR_ENABLED" == "1" ]; then
export START_CMD="${START_CMD:-cosmovisor run start}"
PREFIX_CMD="cosmovisor run"
elif [ -n "$SNAPSHOT_PATH" ]; then
PREFIX_CMD="snapshot.sh"
else
export START_CMD="${START_CMD:-$PROJECT_BIN start}"
PREFIX_CMD=
fi
export PROJECT_ROOT="/root/$PROJECT_DIR"
export CONFIG_PATH="${CONFIG_PATH:-$PROJECT_ROOT/$CONFIG_DIR}"
Expand Down Expand Up @@ -316,10 +318,10 @@ if [[ ! -f "$PROJECT_ROOT/data/priv_validator_state.json" ]]; then
echo '{"height":"0","round":0,"step":0}' > "$PROJECT_ROOT/data/priv_validator_state.json"
fi

if [ -n "$SNAPSHOT_PATH" ]; then
exec snapshot.sh "$START_CMD"
if [ "$#" -ne 0 ]; then
exec $PREFIX_CMD "$@"
elif [ -n "$START_CMD" ]; then
exec $START_CMD
exec $PREFIX_CMD $START_CMD
else
exec "$@"
exec $PREFIX_CMD start
fi

0 comments on commit 6538e60

Please sign in to comment.