Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make COSMOVISOR_ENABLED and START_CMD work as intended #528

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -190,5 +190,4 @@ RUN curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2
COPY run.sh snapshot.sh /usr/bin/
RUN chmod +x /usr/bin/run.sh /usr/bin/snapshot.sh
ENTRYPOINT ["run.sh"]

CMD $START_CMD
CMD []
14 changes: 9 additions & 5 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,8 +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 $PREFIX_CMD $START_CMD
else
exec "$@"
exec $PREFIX_CMD $PROJECT_BIN start
fi