This is a Python web application built using the Flask framework. This README will guide you through the setup, usage, and structure of this project.
Before you begin, ensure you have the following prerequisites installed on your system:
- Python 3.x
- pip (Python Package Manager): You should have pip installed with Python by default.
- Redis
- Create a virtual environment to isolate project dependencies:
python -m venv venv - Activate the virtual environment:
source venv/bin/activate - Copy sample env file:
cp .env.example .env - Install project dependencies:
pip install -r requirements.txt
Run the following command:
python application.py
Note that it can take a few minutes to start server for the first time. This is because it needs to download and process ISS trajectory data.
Optionally, you can start periodic job that will update ISS trajectory data every hour:
celery -A tasks worker -B
The project structure is organized as follows:
nasa-iss-backend/
│
├── rest/
│ ├── __init__.py
│ ├── routes
│ ├── services
│ └── tasks.py
│
├── venv/ (Virtual Environment)
│
├── .env
├── README.md
├── requirements.txt
├── alivebot.py
├── application.py
└── tasks.py
rest/routes This is where Flask route handlers live.
rest/services This is where various helpers live.
rest/tasks.py This is where definitions of periodic tasks live.
alivebot.py This is a script that checks current server status and reports it to Slack channel
application.py This is an entrypoint of the Flask application.
tasks.py This is a script that configures periodic task execution.
- Create RDS user
CREATE ROLE nominatim WITH PASSWORD 'qaIACxO6wMR3' CREATEDB CREATEROLE LOGIN; GRANT rds_superuser TO nominatim; - Import and start Nominatim server (requires at least 64GB of RAM + 64GB swap, 140GB of free space, 200GB of free space on RDS)
This step takes about 1.5 days to finish.
sudo docker run -it \ -d \ -e PBF_URL=https://ftpmirror.your.org/pub/openstreetmap/pbf/planet-latest.osm.pbf \ -e NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;host=osm-nominatim-db.cidzi6gdqymv.us-east-1.rds.amazonaws.com;user=nominatim;password=qaIACxO6wMR3" \ -e PGHOST=osm-nominatim-db.cidzi6gdqymv.us-east-1.rds.amazonaws.com \ -e PGDATABASE=nominatim \ -e PGUSER=nominatim \ -e PGPASSWORD=qaIACxO6wMR3 \ -e FREEZE=true \ -e IMPORT_STYLE=admin \ -e NOMINATIM_TOKENIZER=icu \ -e IMPORT_WIKIPEDIA=true \ -p 8080:8080 \ --name nominatim \ mediagis/nominatim:4.3 - To start Nominatim server without recreating database:
Nominatim warms up database caches upon startup, which takes about 3 minutes. The service is not accessible during this process.
touch import-finished sudo docker run -it \ -d \ -e PBF_URL=https://ftpmirror.your.org/pub/openstreetmap/pbf/planet-latest.osm.pbf \ -e NOMINATIM_DATABASE_DSN="pgsql:dbname=nominatim;host=osm-nominatim-db.cidzi6gdqymv.us-east-1.rds.amazonaws.com;user=nominatim;password=qaIACxO6wMR3" \ -e PGHOST=osm-nominatim-db.cidzi6gdqymv.us-east-1.rds.amazonaws.com \ -e PGDATABASE=nominatim \ -e PGUSER=nominatim \ -e PGPASSWORD=qaIACxO6wMR3 \ -e FREEZE=true \ -e IMPORT_STYLE=admin \ -e NOMINATIM_TOKENIZER=icu \ -e IMPORT_WIKIPEDIA=true \ -p 8080:8080 \ -v ./import-finished:/var/lib/postgresql/14/main/import-finished \ --name nominatim \ mediagis/nominatim:4.3