Name: feinstaub-api
Owner: Open Data Stuttgart
Description: Django project to store sensor pushed via REST api
Created: 2015-03-27 19:10:37.0
Updated: 2018-05-06 12:34:39.0
Pushed: 2017-12-04 13:41:27.0
Homepage: null
Size: 148
Language: Python
GitHub Committers
User | Most Recent Commit | # Commits |
---|
Other Committers
User | Most Recent Commit | # Commits |
---|
Api to save data from sensors (especially particulates sensors).
Daily CSV dumps: http://archive.luftdaten.info/
(with virtualenvwrapper)
mkvirtualenv feinstaub-api -p /usr/bin/python3
sing docker and docker-compose (for development)
Setup
stall docker and docker-compose
ocker-compose up -d`
it
ybe create a database (if non existent):
docker-compose run –rm web python3 manage.py reset_db docker-compose run –rm web python3 manage.py migrate
roduction tutorial
server installation protocol see:
s://github.com/opendata-stuttgart/meta/wiki/Protokoll-installation-von-feinstaub-api-server
setup of production.py
py ``feinstaub/settings/production_example.py`` to ``feinstaub/settings/production.py``
ANGE the annotated things. really!
starting/creating docker instances
docker run -d –restart=always -v $(pwd)/../feinstaub-db-data:/var/lib/postgres –name feinstaub-db postgres:9.6
docker run -d –restart=always -v $(pwd)/../feinstaub-redis-data:/data –name feinstaub-redis redis redis-server
docker run -d –name feinstaub-data -v /home/uid1000 aexea/aexea-base
docker build –tag=feinstaub-prod .
docker run -d -v $(pwd)/../feinstaub-data:/home/uid1000 –link feinstaub-db:db –link feinstaub-redis:redis –restart=always –name feinstaub feinstaub-prod
docker run –name feinstaub-nginx –net=“host” -v $(pwd)/../feinstaub-data:/home/uid1000 –restart=always -v pwd
/nginx.conf:/etc/nginx/nginx.conf -d nginx:1.11
./update.sh
Notes
wap
b on server are not enough.
te swap using:
sudo dd if=/dev/zero of=/swapfile bs=1024 count=524288 sudo chmod 600 /swapfile sudo mkswap /swapfile sudo swapon /swapfile
ake the swap reboot persistent add the following line in `/etc/fstab`:
/swapfile swap swap defaults 0 0
roduction database for development
on production
er exec feinstaub-db pg_dump -Fc -h localhost -v -U postgres feinstaub > feinstaub-backup.sql
better:
er run --rm -ti -v `pwd`:/root --link feinstaub-db:db postgres:9.4 pg_dump -U postgres -h db feinstaub -f /root/feinstaub-db.pgdump
on development
ipaddress of postgres-container:
er inspect feinstaubapi_db_1 | grep IPAddress
ore database:
estore -C -v -h [ipaddress-of-db-container] -U postgres -d feinstaub feinstaub-backup.sql
dump development database
volume mount to db container:
volumes:
and run dump command:
er-compose run --rm db pg_dump -Fc -h db -v -U postgres feinstaub -f /opt/code/feinstaub-api-db.dump