From e9ffc167d450a1064c43832fbf19883c6e93bca3 Mon Sep 17 00:00:00 2001 From: Paul Leclercq Date: Sun, 25 Feb 2024 21:05:54 +0100 Subject: [PATCH] Monitoring/cron duration (#117) * monitor: cron duration * fix: monitor cron duration --- docker-compose.yml | 1 + .../data_ingestion/ingest_db/ingest_sitemap_in_db.py | 4 ++-- quotaclimat/data_processing/mediatree/api_import.py | 12 ++---------- 3 files changed, 5 insertions(+), 12 deletions(-) diff --git a/docker-compose.yml b/docker-compose.yml index d7b017d2..993c533d 100644 --- a/docker-compose.yml +++ b/docker-compose.yml @@ -134,6 +134,7 @@ services: POSTGRES_PORT: 5432 PORT: 5050 # healthcheck HEALTHCHECK_SERVER: "0.0.0.0" + SENTRY_DSN: prod_only # START_DATE: 1704576615 # to test batch import # UPDATE: "true" # to batch update PG # CHANNEL : fr3-idf # to reimport only one channel diff --git a/quotaclimat/data_ingestion/ingest_db/ingest_sitemap_in_db.py b/quotaclimat/data_ingestion/ingest_db/ingest_sitemap_in_db.py index 596f282b..7372684f 100644 --- a/quotaclimat/data_ingestion/ingest_db/ingest_sitemap_in_db.py +++ b/quotaclimat/data_ingestion/ingest_db/ingest_sitemap_in_db.py @@ -70,8 +70,8 @@ async def main(): time.sleep(60 * minutes) res=health_check_task.cancel() - logging.info("Exiting with success") - sys.exit(0) + logging.info("Exiting with success") + sys.exit(0) if __name__ == "__main__": # create logger with 'spam_application' diff --git a/quotaclimat/data_processing/mediatree/api_import.py b/quotaclimat/data_processing/mediatree/api_import.py index d49a7865..9b54f370 100644 --- a/quotaclimat/data_processing/mediatree/api_import.py +++ b/quotaclimat/data_processing/mediatree/api_import.py @@ -262,17 +262,9 @@ async def main(): # Wait for both tasks to complete await event_finish.wait() - # only for scaleway - delay for serverless container - # Without this we have a CrashLoopBackOff (Kubernetes health error) - if (os.environ.get("ENV") != "dev" and os.environ.get("ENV") != "docker"): - minutes = 15 - seconds_to_minute = 60 - logging.warning(f"Sleeping {minutes} before safely exiting scaleway container") - sleep(seconds_to_minute * minutes) - res=health_check_task.cancel() - logging.info("Exiting with success") - sys.exit(0) + logging.info("Exiting with success") + sys.exit(0) if __name__ == "__main__": # create logger with 'spam_application'