Environment Variables

The server will check a number of environment variables to configure itself.

Setting Environment variables

Environment variables can be set in many ways depending on the the OS and/or the tool used to launch the server. This is a list of common possible ways:

  • Windows Powershell: $env:VARIABLE_NAME = "value" (code must be run in the same shell)

  • Windows Command Prompt: set VARIABLE_NAME=value (code must be run in the same shell) !! Do not use quotes as they will be included in the value

  • Windows Settings: Control Panel > System > Advanced System Settings > Environment Variables

  • Linux BASH: export VARIABLE_NAME=value (code must be run in the same shell)

  • VSCode: launch.json > env > VARIABLE_NAME

{
    "version": "0.2.0",
    "configurations": [
        {
            ...
            "env": {
                "VARIABLE_NAME_1": "VALUE_1",
                ...
            },
            ...
        }
    ]
}
  • Docker: docker run -e VARIABLE_NAME=value ...

  • Docker: docker run --env-file .env ... where .env is a file with the format

VARIABLE_NAME_1=VALUE_1
...
VARIABLE_NAME_N=VALUE_N

App variable List

Variables used by the application.

Title

Variable

Default

Usage

OCT_BASE_DIR

false

Path to the base directory of the project.

If no other paths are configured using environment

variables, the server database, plugin files

and downloaded models will be stored here.

LOAD_ON_START

false

Will automatically load the most used

source/destination languages and most used models

for that language combination at server start

AUTOCREATE_LANGUAGES

false

Will force the server to automatically

create/update the Language entries in the database.

DEVICE

cpu

Which device to use for plugins that support it.

Currently allowed: cpu, cuda

NUM_MAIN_WORKERS

4

Number of WorkerMessageQueue workers handling

incoming OCR_TSL post requests

NUM_BOX_WORKERS

1

Number of WorkerMessageQueue workers handling

box_ocr pipelines (Should be set as 1 until the

pipeline is build to handle multiple concurrent

request efficiently without slowdowns)

NUM_OCR_WORKERS

1

Number of WorkerMessageQueue workers handling

ocr pipelines (Should be set as 1 until the

pipeline is build to handle multiple concurrent

request efficiently without slowdowns)

NUM_TSL_WORKERS

1

Number of WorkerMessageQueue workers handling

translation pipelines (Should be set as 1 until

the pipeline is build to handle multiple

concurrent request efficiently without slowdowns)

run_server.py variable List

This variables are used if running the server using the provided run_server.py script. This includes the windows release file and docker image that are based on the same script.

Title

Variable

Default

Usage

DJANGO_SUPERUSER_USERNAME

admin

Username for the superuser to be created

DJANGO_SUPERUSER_PASSWORD

password

Password for the superuser to be created

OCT_DJANGO_BIND_ADDRESS

127.0.0.1

Address to bind the server to

OCT_DJANGO_PORT

4000

Port the server will listen to

OCT_GUNICORN_USER

current user

User to run the server as if using gunicorn.

OCT_GUNICORN_TIMEOUT

1200

Timeout for gunicorn workers

OCT_GUNICORN_NUM_WORKERS

1

Number of gunicorn workers

Plugin specific variables

See plugins doc

Server variable List

Variables used specifically by the DJANGO server.

Title

Variable

Default

Usage

DJANGO_DEBUG

false

Whether to run the server in debug (true) or production (false) mode

DJANGO_LOG_LEVEL

INFO

python logging level for

DATABASE_NAME

db.sqlite3

For sqlite3 this is the path to the database file. For other backend it should be the name of the database

DATABASE_ENGINE

django.db.backends.sqlite3

Change this to either a Django or 3rd party provided backend to use another Database type

DATABASE_HOST

optional

Required if using another db back-end

DATABASE_PORT

optional

Required if using another db back-end

DATABASE_USER

optional

Probably required if using another db back-end

DATABASE_PASSWORD

optional

Probably required if using another db back-end