diff --git a/Dockerfile b/Dockerfile index 3b3539217..d14f867aa 100644 --- a/Dockerfile +++ b/Dockerfile @@ -774,7 +774,7 @@ RUN set -x && \ printf -- "qjs_version = '%s'\n" "${qjs_version}" >> /app/common/third_party_versions.py # Create a healthcheck -HEALTHCHECK --interval=1m --timeout=10s --start-period=3m CMD ["/app/healthcheck.py", "http://127.0.0.1:8080/healthcheck"] +HEALTHCHECK --interval=1m --timeout=10s --start-period=3m CMD ["/app/healthcheck.py"] # ENVS and ports ENV DENO_DIR="/config/cache/deno" \ diff --git a/tubesync/healthcheck.py b/tubesync/healthcheck.py index 5cdc63ed1..9c36c9fe5 100755 --- a/tubesync/healthcheck.py +++ b/tubesync/healthcheck.py @@ -31,15 +31,21 @@ def do_heatlhcheck(url): return response.status_code == 200 -if __name__ == '__main__': +if '__main__' == __name__: # if it is marked as intentionally down, nothing else matters if os.path.exists('/run/service/gunicorn/down'): sys.exit(0) try: url = sys.argv[1] except IndexError: - sys.stderr.write('URL must be supplied\n') - sys.exit(1) + try: + from tubesync.gunicorn import get_bind + host_port = get_bind() + except: + host = os.getenv('LISTEN_HOST', '127.0.0.1') + port = os.getenv('LISTEN_PORT', '8080') + host_port = f'{host}:{port}' + url = f'http://{host_port}/healthcheck' if do_heatlhcheck(url): sys.exit(0) else: