drogon icon indicating copy to clipboard operation
drogon copied to clipboard

Support .env config

Open ahmedkamalio opened this issue 3 years ago • 1 comments

It's a very common practice to use a .env file to load server configuration instead of the config.json file, that being said, this issue suggests to add support to loading config from .env file.

an example .env file would be as follows

[DB_CLIENTS]
RDBMS=postgresql
HOST=127.0.0.1
PORT=5432
DBNAME= postgres
USER=postgres
PASSWD=""
IS_FAST=true
NUMBER_OF_CONNECTIONS=1
TIMEOUT=-1.0

[REDIS_CLIENTS]
HOST=127.0.0.1
PORT=6379
PASSWD=""
DB=0
IS_FAST=true
NUMBER_OF_CONNECTIONS=1
TIMEOUT=-1.0

[LISTENERS]
ADDRESS=0.0.0.0
PORT=80
HTTPS=false

[LISTENERS]
ADDRESS=0.0.0.0
PORT=443
HTTPS=true
CERT=""
KEY=""
USE_OLD_TLS=false

[APP]
NUMBER_OF_THREADS=0
ENABLE_SESSION=true
SESSION_TIMEOUT=0
DOCUMENT_ROOT="./"
USE_IMPLICIT_PAGE=false
UPLOAD_PATH="uploads"
MAX_CONNECTIONS=100000
MAX_CONNECTIONS_PER_IP=0
LOAD_DYNAMIC_VIEWS=false
ENABLE_UNICODE_ESCAPING_IN_JSON=true
RUN_AS_DAEMON=false
HANDLE_SIG_TERM=true
RELAUNCH_ON_ERROR=true
USE_SENDFILE=true
USE_GZIP=true
USE_BROTLI=false
STATIC_FILES_CACHE_TIME=0
IDLE_CONNECTION_TIMEOUT=30
SERVER_HEADER_FIELD=drogon/version
ENABLE_SERVER_HEADER=true
ENABLE_DATE_HEADER=true
KEEPALIVE_REQUESTS=0
PIPELINING_REQUESTS=0
GZIP_STATIC=true
BR_STATIC=true
CLIENT_MAX_BODY_SIZE=1M
CLIENT_MAX_MEMORY_BODY_SIZE=64K
CLIENT_MAX_WEBSOCKET_MESSAGE_SIZE=128K
REUSE_PORT=true

[LOG]
LOG_PATH=""
LOGFILE_BASE_NAME=drogon
LOG_SIZE_LIMIT=10000000 # 10MB
LOG_LEVEL=DEBUG

this's the equivalent of the config.json file created with new dragon project.

ahmedkamalio avatar Feb 26 '22 10:02 ahmedkamalio

Thanks for the feature request.

Could you please clarify one question: Do you suggest that Drogon should adopt the INI file format in addition to JSON, or do you suggest that Drogon should support all configuration parameters via environment variables, and the .env file would be a means to an end for feeding the framework with variables?

rbugajewski avatar Feb 28 '22 15:02 rbugajewski