Production
NOTE: This documentation is outdated
Deployment
When pushing new changes into the production system the following routine should be performed:
Check unit and integration tests
Backup code and database
Stop web service
sudo supervisorctl stop oldpPull changes from repo
git pullRun
Activate production environment (only on oldp1)
source commands.shActivate Python environment
source env/bin/activatepip install -r requirements.txtnpm install./manage.py render_html_pagesnpm run-script build./manage.py collectstatic --no-input./manage.py compilemessages --l de --l en./manage.py rebuild_indexor./manage.py update_index
Run
./manage.py migrateStart web service
sudo supervisorctl start oldp
Upgrade theme
# Activate python environment
source env/bin/activate
# Install Theme package with full path
pip install -e /srv/oldp/oldp-de/
Commands
Commands for running OLDP in production mode.
./manage.py process_cases --limit 20 --empty --input /var/www/apps/oldp/data/split001/
./manage.py set_law_book_order
./manage.py set_law_book_revision
Dump data
Create JSONL files from API data:
# Dump JSON files
./manage.py dump_api_data ./workingdir/2020-10-10-dump/
# Dump references
./manage.py dump_references ./workingdir/2020-10-10-dump/
# Compress all dumps
gzip -r ./workingdir/2020-10-10-dump/*
Clean up database
DELETE FROM cases_case;
ALTER TABLE cases_case AUTO_INCREMENT=1;
DELETE FROM cases_relatedcase;
ALTER TABLE cases_relatedcase AUTO_INCREMENT=1;
DELETE FROM courts_court;
ALTER TABLE courts_court AUTO_INCREMENT=1;
DELETE FROM courts_city;
ALTER TABLE courts_city AUTO_INCREMENT=1;
DELETE FROM courts_state;
ALTER TABLE courts_state AUTO_INCREMENT=1;
DELETE FROM courts_country;
ALTER TABLE courts_country AUTO_INCREMENT=1;
DELETE FROM references_casereferencemarker;
ALTER TABLE references_casereferencemarker AUTO_INCREMENT=1;
Helper commands for migration
# Set missing previous law references to NULL
UPDATE laws_law
SET previous_id = NULL
WHERE id in (
SELECT * FROM (
select l.id
from laws_law l
left join laws_law p
on p.id = l.previous_id
WHERE l.previous_id IS NOT NULL AND p.id IS NULL
) as t);