-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #31 from neutrons/cron-and-logging
Add cron job to periodically purge
- Loading branch information
Showing
19 changed files
with
88 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,6 @@ target/ | |
|
||
#Ipython Notebook | ||
.ipynb_checkpoints | ||
|
||
# Ruff cache | ||
.ruff_cache |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,3 +8,5 @@ coverage: | |
default: | ||
target: 80% | ||
threshold: 10% | ||
ignore: | ||
- "src/apps/plots/migrations" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
FROM continuumio/miniconda3:23.10.0-1 AS base | ||
|
||
### System dependencies and cron job setup | ||
RUN apt-get update -y && \ | ||
# apt upgrade -y && \ | ||
apt-get install -y \ | ||
vim cron | ||
|
||
# Set up cron job to purge expired data once a month | ||
COPY scripts/periodic-purge.sh /var/opt/ | ||
RUN echo "0 0 1 * * /var/opt/periodic-purge.sh >> /var/log/cron.log 2>&1" > /etc/cron.d/root && \ | ||
chmod 0644 /etc/cron.d/root && \ | ||
crontab /etc/cron.d/root && \ | ||
touch /var/log/cron.log | ||
|
||
### Environment setup | ||
FROM base AS build | ||
|
||
COPY environment.yml . | ||
RUN conda env create | ||
|
||
WORKDIR /var/www/livedata | ||
COPY src app | ||
RUN mkdir ./static | ||
|
||
### Final image | ||
FROM build AS final | ||
|
||
COPY deploy/django/docker-entrypoint.sh /usr/bin/ | ||
RUN chmod +x /usr/bin/docker-entrypoint.sh | ||
ENTRYPOINT ["conda", "run", "--no-capture-output", "-n", "livedata", "/usr/bin/docker-entrypoint.sh"] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -11,7 +11,6 @@ dependencies: | |
- psycopg=3.2 | ||
- gunicorn | ||
- pytest | ||
- build | ||
- versioningit | ||
- toml | ||
- pre-commit | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
#!/usr/bin/env bash | ||
. /opt/conda/etc/profile.d/conda.sh | ||
printf "=%.0s" {1..88} | ||
printf "\nStarting periodic purge - $(date)\n" | ||
conda run -n livedata python /var/www/livedata/app/manage.py purge_expired_data | ||
printf "=%.0s" {1..88}; printf "\n" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ | |
|
||
class PlotsConfig(AppConfig): | ||
name = "apps.plots" | ||
default_auto_field = "django.db.models.BigAutoField" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 27 additions & 0 deletions
27
src/apps/plots/migrations/0003_alter_default_auto_fields.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
# Generated by Django 4.2.15 on 2024-08-23 14:47 | ||
|
||
from django.db import migrations, models | ||
|
||
|
||
class Migration(migrations.Migration): | ||
dependencies = [ | ||
("plots", "0002_datarun_expiration_date"), | ||
] | ||
|
||
operations = [ | ||
migrations.AlterField( | ||
model_name="datarun", | ||
name="id", | ||
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"), | ||
), | ||
migrations.AlterField( | ||
model_name="instrument", | ||
name="id", | ||
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"), | ||
), | ||
migrations.AlterField( | ||
model_name="plotdata", | ||
name="id", | ||
field=models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name="ID"), | ||
), | ||
] |