Skip to content

Latest commit

 

History

History
70 lines (46 loc) · 2.42 KB

File metadata and controls

70 lines (46 loc) · 2.42 KB

Gold-digger (Exchange rates service)

Used technologies

Development setup

python -m venv .env
. ./.env/bin/activate  # or for BFU .env\Scripts\activate.bat
pip install -U pip wheel
pip install --use-wheel -r requirements-dev.txt

Now you can run test by command py.test or start watchdog that run the tests after every save of Python file by command ptw.

Create PostgreSQL database and user named gold-digger.

Create local configuration file called gold_digger/config/params_local.py with configuration for local machine. For development purposes there is no configuration required so file may look like the below one:

# -*- coding: utf-8 -*-

LOCAL_CONFIG_PARAMS = {

}

Usage

Create local database and update connection parameters.

  • python -m gold_digger initialize-db to create tables
  • python -m gold_digger update [--date="yyyy-mm-dd"] to update rates of specified date (default today)
  • python -m gold_digger update-all [--origin-date="yyyy-mm-dd"] to update rates since specified origin date
  • python -m gold_digger serve starts API server

API endpoints

Docker

Ensure you have created local params file according to Development setup section. Then build docker image.

docker build -t gold-digger-ubuntu .

If you are connecting to local database on the host (outside the container) run the container with --net=host option.

docker run --name gold-digger --net=host -t -i -p 8000:8000 gold-digger-ubuntu

Run production container as daemon (production).

docker run --name gold-digger -d -p 8000:8000 gold-digger-ubuntu

Docker container starts the Gunicorn server. Web server is kept alive by supervisor. Cron performs daily updates at 00:05.