Skip to content

Commit

Permalink
Implement Docker container for cron #2
Browse files Browse the repository at this point in the history
  • Loading branch information
kcloud committed Jan 30, 2023
1 parent 1e2bec2 commit 243a582
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
21 changes: 21 additions & 0 deletions Dockerfile.cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM python:3.9

ENV PYTHONUNBUFFERED 1
RUN apt-get update && apt-get install -y cron && which cron && rm -rf /etc/cron.*/*
RUN apt-get -y install python3-pip
RUN pip install --upgrade pip
RUN pip install django

RUN mkdir /code
WORKDIR /code
ADD . /code/
RUN pip install --upgrade pip && pip install -r requirements.txt
RUN chmod +x /code

RUN ln -s /usr/local/bin/python3 /code/pisces/python
ADD ./cron/pisces_cron /etc/cron.d/pisces_cron
RUN chmod 644 /etc/cron.d/pisces_cron
RUN crontab /etc/cron.d/pisces_cron
RUN mkdir -p /var/log/pisces-cron
ENTRYPOINT ["/code/cron/entrypoint.sh"]
CMD ["cron","-f","-l","2"]
7 changes: 7 additions & 0 deletions cron/entrypoint.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/sh

env >> environment

# execute CMD
echo "$@"
exec "$@"
16 changes: 16 additions & 0 deletions cron/pisces_cron
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
# Don't remove empty line at end of file. It is required for cron to run.
PISCES_ROOT=/code/pisces
5 0,12 * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.CleanUpCompleted" >> /var/log/pisces-cron/pisces-cleanupcompleted.txt 2>&1
0 0 */2 * * $PISCES_ROOT/python -u /code/manage.py runcrons "transformer.cron.CheckMissingOnlineAssets" >> /var/log/pisces-cron/pisces-online.txt 2>&1
02,32 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.UpdatedArchivesSpaceFamilies" >> /var/log/pisces-cron/pisces-families.txt 2>&1
07,37 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.UpdatedArchivesSpaceOrganizations" >> /var/log/pisces-cron/pisces-organizations.txt 2>&1
12,42 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.UpdatedArchivesSpacePeople" >> /var/log/pisces-cron/pisces-people.txt 2>&1
17,47 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.UpdatedArchivesSpaceResources" >> /var/log/pisces-cron/pisces-resources.txt 2>&1
22,52 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.UpdatedArchivesSpaceArchivalObjects" >> /var/log/pisces-cron/pisces-archivalobjects.txt 2>&1
#05,35 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.UpdatedCartographerArrangementMapComponents" >> /var/log/pisces-cron/pisces-arrangementmaps.txt
59,29 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.DeletedArchivesSpaceFamilies" >> /var/log/pisces-cron/pisces-families-deleted.txt
04,34 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.DeletedArchivesSpaceOrganizations" >> /var/log/pisces-cron/pisces-organizations-deleted.txt
09,39 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.DeletedArchivesSpacePeople" >> /var/log/pisces-cron/pisces-people-deleted.txt
14,44 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.DeletedArchivesSpaceResources" >> /var/log/pisces-cron/pisces-resources-deleted.txt
19,49 * * * * $PISCES_ROOT/python -u /code/manage.py runcrons "fetcher.cron.DeletedArchivesSpaceArchivalObjects" >> /var/log/pisces-cron/pisces-archivalobjects-deleted.txt

0 comments on commit 243a582

Please sign in to comment.