From f16a5270027e5960e2ddc3a1b8f88101426769da Mon Sep 17 00:00:00 2001 From: mjanez <96422458+mjanez@users.noreply.github.com> Date: Sat, 22 Apr 2023 15:57:09 +0200 Subject: [PATCH] Fix cronjobs by use scheduler Schedule a recurring task to run at a specific time interval and check if gunicorn is running. Kill any gunicorn process with "gunicorn" or "pycsw.wsgi:application" in its name or command line. --- .env.example | 7 ++++++- ckan-pycsw/Dockerfile | 6 ++++-- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/.env.example b/.env.example index 62860b1..8f9c8f8 100644 --- a/.env.example +++ b/.env.example @@ -49,7 +49,13 @@ PYCSW_URL=http://localhost/csw # SCHEMAS: ckan2pycsw/model/dataset.py - Dataset type PYCSW_CKAN_SCHEMA=iso19139_geodcatap PYCSW_OUPUT_SCHEMA=iso19139_inspire +# ckan-pycsw schedule +## ckan2pycsw days between each scheduler job PYCSW_CRON_DAYS_INTERVAL=2 +# ckan2pycsw hour of start of the scheduler job (0-23) +PYCSW_CRON_HOUR_START=4 +## Timezone +TZ=UTC # CKAN databases POSTGRES_USER=ckan @@ -87,7 +93,6 @@ CKAN_SMTP_STARTTLS=True CKAN_SMTP_USER=user CKAN_SMTP_PASSWORD=pass CKAN_SMTP_MAIL_FROM=ckan@localhost -TZ=UTC ## Customize which text formats the text_view plugin will show CKAN__PREVIEW__JSON_FORMATS="json jsonld" # html htm rdf+xml owl+xml xml n3 n-triples turtle plain atom csv tsv rss txt json diff --git a/ckan-pycsw/Dockerfile b/ckan-pycsw/Dockerfile index e6fe7f3..47571bd 100644 --- a/ckan-pycsw/Dockerfile +++ b/ckan-pycsw/Dockerfile @@ -12,10 +12,12 @@ ENV PYCSW_URL=http://localhost:${PYCSW_PORT}/ ENV DEV_MODE=False ENV TIMEOUT=300 ENV PYCSW_CRON_DAYS_INTERVAL=2 +ENV PYCSW_CRON_HOUR_START=4 WORKDIR ${APP_DIR} COPY pycsw/conf/pycsw.conf.template pycsw/entrypoint.sh . -EXPOSE 8080/TCP +EXPOSE ${PYCSW_PORT}/TCP + ENTRYPOINT ["/bin/bash", "./entrypoint.sh"] -CMD ["pdm", "run", "python3", "-m", "gunicorn", "pycsw.wsgi:application", "-b", "0.0.0.0:${PYCSW_PORT}"] \ No newline at end of file +CMD ["tail", "-f", "/dev/null"] \ No newline at end of file