From 0b09ca48ebe6e8a518826e34c1f56c25d13a5336 Mon Sep 17 00:00:00 2001 From: Jonathan Green Date: Tue, 16 Apr 2024 20:25:04 -0300 Subject: [PATCH] Fix celery log folder creation (#1787) --- core/celery/tasks/custom_list.py | 2 ++ docker/Dockerfile | 4 ---- docker/runit-scripts/beat/run | 11 +++++++++++ docker/runit-scripts/worker-default/run | 7 +++++++ docker/runit-scripts/worker-high/run | 7 +++++++ 5 files changed, 27 insertions(+), 4 deletions(-) diff --git a/core/celery/tasks/custom_list.py b/core/celery/tasks/custom_list.py index 9ee7023fa6..17e6761674 100644 --- a/core/celery/tasks/custom_list.py +++ b/core/celery/tasks/custom_list.py @@ -125,5 +125,7 @@ def update_custom_lists(task: Task) -> None: select(CustomList.id).where(CustomList.auto_update_enabled == True) ).all() + task.log.info(f"Updating {len(custom_lists)} custom lists.") + for custom_list in custom_lists: update_custom_list.delay(custom_list.id) diff --git a/docker/Dockerfile b/docker/Dockerfile index 1713c07cb8..c084f24620 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -46,10 +46,6 @@ FROM common AS scripts # Set the local timezone and setup cron ENV TZ=US/Eastern RUN ln -snf /usr/share/zoneinfo/$TZ /etc/localtime && \ - mkdir /var/log/celery && \ - chown simplified:simplified /var/log/celery && \ - mkdir /var/run/celery && \ - chown simplified:simplified /var/run/celery && \ touch /var/log/cron.log # Copy cron config into container diff --git a/docker/runit-scripts/beat/run b/docker/runit-scripts/beat/run index 77fa228a66..b4c6d98a0c 100755 --- a/docker/runit-scripts/beat/run +++ b/docker/runit-scripts/beat/run @@ -1,6 +1,17 @@ #!/bin/bash set -e +# Set the working directory to the root of the project cd /var/www/circulation source env/bin/activate + +# Make sure the log directory exists and is writable +mkdir -p /var/log/celery +chown 1000:adm /var/log/celery + +# Make sure the run directory exists and is writable +mkdir -p /var/run/celery +chown 1000:1000 /var/run/celery + +# Start the celery beat process exec env/bin/celery -A "core.celery.worker.app" beat --uid 1000 --gid 1000 --logfile /var/log/celery/beat.log -s /var/run/celery/beat-schedule diff --git a/docker/runit-scripts/worker-default/run b/docker/runit-scripts/worker-default/run index b1a5873ff0..4a98f89750 100755 --- a/docker/runit-scripts/worker-default/run +++ b/docker/runit-scripts/worker-default/run @@ -1,6 +1,13 @@ #!/bin/bash set -e +# Set the working directory to the root of the project cd /var/www/circulation source env/bin/activate + +# Make sure the log directory exists and is writable +mkdir -p /var/log/celery +chown 1000:adm /var/log/celery + +# Start the celery worker exec env/bin/celery -A "core.celery.worker.app" worker --uid 1000 --gid 1000 --autoscale 4,1 --hostname default@%h -Q high,default --logfile /var/log/celery/default.log diff --git a/docker/runit-scripts/worker-high/run b/docker/runit-scripts/worker-high/run index f134b049f5..6b2a65c869 100755 --- a/docker/runit-scripts/worker-high/run +++ b/docker/runit-scripts/worker-high/run @@ -1,6 +1,13 @@ #!/bin/bash set -e +# Set the working directory to the root of the project cd /var/www/circulation source env/bin/activate + +# Make sure the log directory exists and is writable +mkdir -p /var/log/celery +chown 1000:adm /var/log/celery + +# Start the celery worker exec env/bin/celery -A "core.celery.worker.app" worker --uid 1000 --gid 1000 --concurrency 1 --hostname high@%h -Q high --logfile /var/log/celery/high.log