From b8bdbb4ad34e2d5f8f4858d9f7f6814b1883ba48 Mon Sep 17 00:00:00 2001 From: Haiko Schol Date: Wed, 23 Oct 2019 17:23:58 +0200 Subject: [PATCH 1/2] Document running periodic data import with systemd Signed-off-by: Haiko Schol --- README.md | 31 +++++++++++++++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/README.md b/README.md index f186a3395..ae35f64d0 100644 --- a/README.md +++ b/README.md @@ -68,6 +68,37 @@ DJANGO_DEV=1 python manage.py test vulnerabilities/tests DJANGO_DEV=1 python manage.py import --all ``` +If you want to run the import periodically, you can use a systemd timer: + +``` +$ cat ~/.config/systemd/user/vulnerablecode.service + +[Unit] +Description=Update vulnerability database + +[Service] +Type=oneshot +Environment="DJANGO_DEV=1" +ExecStart=/path/to/venv/bin/python /path/to/vulnerablecode/manage.py import --all + +$ cat ~/.config/systemd/user/vulnerablecode.timer + +[Unit] +Description=Periodically update vulnerability database + +[Timer] +OnCalendar=daily + +[Install] +WantedBy=multi-user.target +``` + +Start it with + +``` +systemctl --user daemon-reload && systemctl --user start vulnerablecode.timer +``` + ## API Start the webserver From 4d1c676c796055570c2c911f105b36dbeb98d839 Mon Sep 17 00:00:00 2001 From: Haiko Schol Date: Sat, 26 Oct 2019 16:25:47 +0200 Subject: [PATCH 2/2] Document running periodic data import on Heroku Signed-off-by: Haiko Schol --- README.md | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/README.md b/README.md index ae35f64d0..19d9f5760 100644 --- a/README.md +++ b/README.md @@ -138,3 +138,13 @@ https://devcenter.heroku.com/articles/deploying-python#how-to-keep-build-artifac 9. Load the data referring to chapter "Data import" above. 10. To check the logs: `heroku logs --tail` + +### Periodic Data Import + +Note: Running jobs with Heroku Scheduler might incur costs. If you haven't already, you need to add a credit card in your account (https://dashboard.heroku.com/account/billing). + +1. Install the Scheduler add-on: `heroku addons:create scheduler:standard` + +2. Open the Scheduler dashboard: `heroku addons:open scheduler` + +3. Click on "Create job" and enter `python manage.py import --all` under "Run Command"