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
  • 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
  • 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
  • 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:3000
  • 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
  • HT_DB_NAME
    • default: db.sqlite3
  • HT_DB_USER
    • default: user
  • HT_DB_PASSWORD
    • default: password
  • HT_DB_HOST
    • default: localhost
  • HT_DB_PORT
  • HT_TEST_DB_NAME

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
  • CELERY_RESULT_BACKEND
    • default: redis://localhost:6379

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. See server/haztrak/settings.py LOGGING section for details.
    • default: verbose

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
  • HT_TRAK_LOG_LEVEL
    • default: Same level specified by HT_LOG_LEVEL if not provided
  • HT_CORE_LOG_LEVEL
    • default: Same level specified by HT_LOG_LEVEL if not provided

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_LEVELs default.

  • CELERY_LOG_LEVEL
    • default: INFO

Client

Required (client)

  • VITE_HT_API_URL
    • Value: host/domain name of the haztrak back end
    • Default: http://localhost:8000
  • 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.