Getting Started¶
Setup Chronos for development¶
The first step when setting up Chronos is to clone the repository:
git clone https://github.com/teknik-eksjo/chronos.git
Create a virtual python environment, activate it and install the python project requirements:
cd chronos/web
python3 -m venv venv
. venv/bin/activate
pip install -r requirements.txt
If needed, also install docker-compose:
pip install docker-compose
From the root directory of the project, bring up the project dependencies:
docker-compose build
docker-compose up -d
Create a .env-file in the web directory. This file is used to set environment variables and the following are needed to use and run chronos:
DEV_DATABASE_URI=postgresql+psycop2://postgres:secretpassword@localhost/development
TEST_DATABASE_URI=postgresql+psycopg2://postgres:secretpassword@localhost/testing
CHRONOS_ADMIN=email@email.com
CHRONOS_ADMIN_FIRST_NAME=Firstname
CHRONOS_ADMIN_LAST_NAME=Lastname
CHRONOS_ADMIN_PASSWORD=password
BROKER_URL=amqp://rabbitmq:secretpassword@localhost//
RESULT_BACKEND=redis://localhost:6379/0
Note
If you are using a Mac with Docker Toolbox for development, localhost should be replaced with the current docker ip.
CHRONOS_ADMIN sets the administrator account email adress.CHRONOS_ADMIN_FIRST_NAME sets the administrator account firstname.CHRONOS_ADMIN_LAST_NAME sets the administrator account lastname.CHRONOS_ADMIN_PASSWORD sets the administrator account password.Initialize the database in the web directory:
cd web
./manage.py deploy
To generate “dummy”-data run:
./manage.py seed
To bring up the development server run:
./manage.py runserver
Database migrations¶
Database-migrations are handled by Flask-migrate.
The database are initalized by running:
./manage.py deploy
To generate a new database migration run:
./manage.py db migrate -m "Commit message."
Before creating the first database migration run:
./manage.py db init
Tests¶
Tests can be run with the following command:
./manage.py test
If there’s tests that use Selenium they can be run with –gui:
./manage.py test --gui
Linting can be run with the following command:
./manage.py lint
Environment Variables¶
The file .env in the web directory can be used to set environment variables. The environment variables can be seen in the config.py file. The file should consist of the following in order for chronos to function:
DEV_DATABASE_URI=postgresql+psycop2://postgres:secretpassword@localhost/development
TEST_DATABASE_URI=postgresql+psycopg2://postgres:secretpassword@localhost/testing
CHRONOS_ADMIN=email@email.com
CHRONOS_ADMIN_FIRST_NAME=Firstname
CHRONOS_ADMIN_LAST_NAME=Lastname
CHRONOS_ADMIN_PASSWORD=password
BROKER_URL=amqp://rabbitmq:secretpassword@localhost//
RESULT_BACKEND=redis://localhost:6379/0
MAIL_USERNAME and MAIL_PASSWORD needs to be set in order to use the email functionality
(the credentials are according to the config.py-file supposed to be for sendgrid.com. This can be changed.).