opendata-stuttgart/feinstaub-api

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

UserMost Recent Commit# Commits

Other Committers

UserEmailMost Recent Commit# Commits

README

feinstaub-api Build Status

Api to save data from sensors (especially particulates sensors).

Note

Daily CSV dumps: http://archive.luftdaten.info/

Installation:
virtualenv

(with virtualenvwrapper)

mkvirtualenv feinstaub-api -p /usr/bin/python3

install packets
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

database

docker run -d –restart=always -v $(pwd)/../feinstaub-db-data:/var/lib/postgres –name feinstaub-db postgres:9.6

redis

docker run -d –restart=always -v $(pwd)/../feinstaub-redis-data:/data –name feinstaub-redis redis redis-server

home

docker run -d –name feinstaub-data -v /home/uid1000 aexea/aexea-base

main image

docker build –tag=feinstaub-prod .

reset database on first run

docker run –rm -ti -v $(pwd)/../feinstaub-data:/home/uid1000 –link feinstaub-db:db feinstaub-prod python3 manage.py reset_db

docker run –rm -ti -v $(pwd)/../feinstaub-data:/home/uid1000 –link feinstaub-db:db feinstaub-prod python3 manage.py migrate

docker run –rm -ti -v $(pwd)/../feinstaub-data:/home/uid1000 –link feinstaub-db:db feinstaub-prod python3 manage.py createsuperuser

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

rebuild, update

./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

This work is supported by the National Institutes of Health's National Center for Advancing Translational Sciences, Grant Number U24TR002306. This work is solely the responsibility of the creators and does not necessarily represent the official views of the National Institutes of Health.