Configuration
Table of Contents
Overview
haztrak expects configurations in form of environment variables supplied at runtime, Yay! For non-containerized local development, you can place '.env' files in the server and client directories, with the outlined values below and the values will be automatically added. You can find example configs here.
Haztrak also comes with Dockerfiles and a docker-compose files, including docker-compose.yaml. Environment variables can be passed to a using docker-composes --env-file flag like so.
docker-compose --env-file configs/.env.dev up --build
Server
Required (server)
The follow variables are required, haztrak will exit if not present.
HT_SECRET_KEY
: Salt for cryptographic hashing,
required by Django
Optional (server)
HT_DEBUG
- Value:
True
orFalse
- Default:
False
- Description: Django's DEBUG value
- Value:
HT_HOST
- Value: host/domain names that Django will serve
- Default: ['localhost']
- Description: the URL that the server will serve from,
see Django's ALLOWED_HOSTS documentation
- Haztrak currently only accepts one value
HT_TIMEZONE
- Value: one of the approved names from the TZ Database list
- Default: 'UTC'
- Description: see Django's documentation
on TIME_ZONE
- In the future,
USE_TZ
will be enabled by default
- In the future,
HT_RCRAINFO_ENV
- Value:
preprod
,prod
, or the base url of the target RCRAInfo environment - Default:
preprod
(for now in the current development phase) - Description: RCRAInfo environment that Haztrak will interface with per the e-Manifest API Client Library
- Value:
HT_CORS_DOMAIN
- Value for cross-origin resource sharing, the domain that the React app is deployed
- Example for local development: should be something like
http://localhost
HT_CACHE_URL
- URL that points to the cache, in this instance Redis
- Example for local development: should be something like
redis://localhost:6379
Database
Technically these are optional. If these environment variables are not found, Haztrak will fall back to a SQLite3 database in the server directory, which may not be recommended for production, but this is an example web application.
HT_DB_ENGINE
- The server driver used by
django's ORM (e.g.,
django.db.backends.postgresql_psycopg2
) - default:
django.db.backends.sqlite3
- The server driver used by
django's ORM (e.g.,
HT_DB_NAME
- default:
db.sqlite3
- default:
HT_DB_USER
- default:
user
- default:
HT_DB_PASSWORD
- default:
password
- default:
HT_DB_HOST
- default:
localhost
- default:
HT_DB_PORT
- default:
5432
- default for postgres is 5342
- default:
HT_TEST_DB_NAME
- Name of database used for testing
defaults to
test
if not present
- Name of database used for testing
defaults to
Celery
Haztrak offloads expensive tasks to a task queue, Celery. It requires access to a message broker like Redis or RabbitMQ.
CELERY_BROKER_URL
- default:
redis://localhost:6379
- default:
CELERY_RESULT_BACKEND
- default:
redis://localhost:6379
- default:
Logging
These configurations control the format and level of logging for our task queue and http server.
HT_LOG_FORMAT
- Value: string corresponding to a formatter,
simple
,verbose
,superverbose
. Seeserver/haztrak/settings.py
LOGGING section for details. - default:
verbose
- Value: string corresponding to a formatter,
logging can be filtered to only include logs that exceed a threshold. We use the python standard library logging module, levels can be found in their documentation here https://docs.python.org/3/library/logging.html#logging-levels
HT_LOG_LEVEL
- default:
INFO
- default:
HT_TRAK_LOG_LEVEL
- default: Same level specified by
HT_LOG_LEVEL
if not provided
- default: Same level specified by
HT_CORE_LOG_LEVEL
- default: Same level specified by
HT_LOG_LEVEL
if not provided
- default: Same level specified by
The HT_TRAK_LOG_LEVEL
and HT_CORE_LOG_LEVEL
are specific to the Trak and Core
django apps, respectively. If none of these variables are supplied, all values
will default to HT_LOG_LEVEL
s default.
CELERY_LOG_LEVEL
- default:
INFO
- default:
Client
Required (client)
VITE_HT_API_URL
- Value: host/domain name of the haztrak back end
- Default:
http://localhost
VITE_HT_ENV
- Default:
PROD
- Options:
PROD
,DEV
,TEST
- Description: The deployment environments,
TEST
mock service worker that intercepts API calls and responds with test data. It can be used for testing, but also to develop the React client without the django server, however it is feature incomplete.
- Default: