diff --git a/Dockerfile b/Dockerfile index 490247a..014eff3 100644 --- a/Dockerfile +++ b/Dockerfile @@ -34,6 +34,7 @@ USER patuser # Get the server files COPY --from=downloader --chown=patuser /patserver/$PA_STREAM_NAME $INSTALL_LOC COPY --chown=patuser ./docker-entrypoint.sh /docker-entrypoint.sh +COPY healthcheck.sh /healthcheck.sh ENV PA_TITANS_ENABLED=yes ENV PA_AI_ENABLED=yes @@ -46,6 +47,7 @@ ENV PA_REPLAY_TIMEOUT=180 ENV PA_GAMEOVER_TIMEOUT=360 ENV PA_EMPTY_TIMEOUT=3600 +HEALTHCHECK CMD /healthcheck.sh VOLUME $REPLAYS_LOC EXPOSE 20545 WORKDIR $INSTALL_LOC diff --git a/healthcheck.sh b/healthcheck.sh new file mode 100755 index 0000000..03d2207 --- /dev/null +++ b/healthcheck.sh @@ -0,0 +1,14 @@ +#!/bin/bash + +# Based on https://stackoverflow.com/questions/9609130/efficiently-test-if-a-port-is-open-on-linux +exec 6<>/dev/tcp/127.0.0.1/20545 +success=$? + +exec 6>&- # close output connection +exec 6<&- # close input connection + +if [[ $? != 0 ]]; then + exit 1 +else + exit 0 +fi