Skip to content

Commit

Permalink
add graceful-run.sh entrypoint
Browse files Browse the repository at this point in the history
Signed-off-by: Denis Baryshev <[email protected]>
  • Loading branch information
dennybaa committed Dec 17, 2021
1 parent 80db4ed commit ae9ac82
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
4 changes: 2 additions & 2 deletions docker/prover/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -29,10 +29,10 @@ RUN apt-get update && apt-get install -y axel ca-certificates tini && rm -rf /va
#ENV MISC_DOCKER_DUMMY_PROVER $MISC_DOCKER_DUMMY_PROVER
COPY --from=builder /usr/src/zksync/target/release/plonk_step_by_step_prover /bin/
COPY --from=builder /usr/src/zksync/target/release/dummy_prover /bin/
COPY docker/prover/prover-entry.sh /bin/
COPY docker/prover/prover-entry.sh docker/prover/graceful-run.sh /bin/
COPY keys/packed /keys/packed
COPY contracts/artifacts/ /contracts/artifacts/

## Mitigate memory leaks when app exists it's restarted
ENTRYPOINT [ "/usr/bin/tini", "-g", "--" ]
CMD while :; do /bin/prover-entry.sh || exit $?; done
CMD ["/bin/graceful-run.sh"]
19 changes: 19 additions & 0 deletions docker/prover/graceful-run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#!/bin/bash
terminating=""

# exit when the second signal received
graceful_exit() {
if [ -n "$terminating" ]; then
exit $code
fi
terminating="yes"
}

trap graceful_exit SIGINT SIGTERM SIGHUP

while : ; do
/bin/prover-entry.sh; code=$?
[ "$terminating" = "yes" ] && exit $code
# restart prover on failure
[ "$code" -eq 0 ] || exit $code
done

0 comments on commit ae9ac82

Please sign in to comment.