From a1388c6446ecee1de6712c9cbbfc3c3ee61581f7 Mon Sep 17 00:00:00 2001 From: mike <219478+ilude@users.noreply.github.com> Date: Wed, 8 May 2024 22:05:15 -0400 Subject: [PATCH] add healthcheck --- Dockerfile | 12 ++++++++---- app/app.py | 5 +++++ app/processors/title_editor.py | 2 +- 3 files changed, 14 insertions(+), 5 deletions(-) diff --git a/Dockerfile b/Dockerfile index 8d1455b..a54caf3 100755 --- a/Dockerfile +++ b/Dockerfile @@ -34,7 +34,6 @@ ENV TERM_SHELL=${TERM_SHELL} RUN apt-get update && apt-get install -y --no-install-recommends \ bash \ - bash-completion \ ca-certificates \ curl \ gosu \ @@ -43,7 +42,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ locales \ make \ tzdata \ - zsh && \ + wget && \ # cleanup apt-get autoremove -fy && \ apt-get clean && \ @@ -110,8 +109,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ openssl \ openssh-client \ sqlite3 \ - libsqlite3-dev \ - wget && \ + libsqlite3-dev && \ apt-get autoremove -fy && \ apt-get clean && \ apt-get autoclean -y && \ @@ -143,6 +141,10 @@ RUN mkdir /cache && \ mkdir -p /app/static/assets &&\ chown -R ${USER}:${USER} /app/static +HEALTHCHECK --interval=10s --timeout=3s --start-period=20s \ + CMD wget --no-verbose --tries=1 --spider --no-check-certificate http://localhost:$PORT/api/healthcheck || exit 1 + + CMD [ "python3", "app.py" ] ############################## @@ -187,6 +189,7 @@ COPY --from=jupyter-builder --chown=${USER}:${USER} ${PYTHON_DEPS_PATH} ${PYTHON RUN apt-get update && apt-get install -y --no-install-recommends \ ansible \ + bash-completion \ dnsutils \ exa \ iproute2 \ @@ -200,6 +203,7 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ tree \ util-linux \ yq \ + zsh \ zsh-autosuggestions \ zsh-syntax-highlighting && \ apt-get autoremove -fy && \ diff --git a/app/app.py b/app/app.py index 644220b..eb45e81 100644 --- a/app/app.py +++ b/app/app.py @@ -107,12 +107,17 @@ def refresh(feed_id): return redirect('/', code=302) +@app.route('/api/healthcheck') +def healthcheck(): + return 'OK', 200 + ############################################################################### # # Main Startup Code # ############################################################################### + if __name__ == '__main__': port = int(os.environ.get("FLASK_PORT", os.environ.get("ONBOARD_PORT", 9830))) development = bool(os.environ.get("FLASK_ENV", "development") == "development") diff --git a/app/processors/title_editor.py b/app/processors/title_editor.py index c45b1b6..678188f 100644 --- a/app/processors/title_editor.py +++ b/app/processors/title_editor.py @@ -79,7 +79,7 @@ def process(self, articles: list[FeedArticle]) -> list[FeedArticle]: for chain in [self.llama3_chain, self.mistral_chain]: try: logger.info(f"Processing title {count}/{total}: {article.original_title}") - logger.debug(f"{self.script_hash}!={article.processed}: {article.processed != self.script_hash}") + # logger.debug(f"{self.script_hash}!={article.processed}: {article.processed != self.script_hash}") # , config={'callbacks': [ConsoleCallbackHandler()]}) result = chain.invoke({"title": article.original_title, "summary": article.description}) article.title = result['title']