Commit a686fe4b authored by Romain Loth's avatar Romain Loth

troubleshooting config via docker-compose volume (new logic for debug...

troubleshooting config via docker-compose volume (new logic for debug messages, run.sh reads ini file, but shell env vars get priority over config vars)
parent 6f4898ab
......@@ -2,18 +2,8 @@
#
# simple web server running services/comex_main_backend:app
if [ -z "$HOST" ]
then export HOST="0.0.0.0"
fi
export COMEX_HOST=$(grep COMEX_HOST config/parametres_comex.ini | perl -pe 's/^[^=]+=\s*//')
echo "using \$COMEX_HOST $COMEX_HOST"
if [ "$DEBUG_FLAG" != true ]
then
gunicorn -b $HOST:9090 services.comex_main_backend:app
else
gunicorn -b $HOST:9090 \
--log-level debug \
services.comex_main_backend:app
# --access-logfile test_gu_access.log
# --error-logfile test_gu_error.log
fi
gunicorn -b $COMEX_HOST:9090 services.comex_main_backend:app
......@@ -31,6 +31,9 @@ from os import path
from traceback import format_tb
from json import dumps
print("HELLO starting comex_main_backend.py====================")
if __package__ == 'services':
# when we're run via import
from services.user import comex_user
......@@ -48,6 +51,10 @@ else:
config = read_config()
# DEBUG
print("config is=====>", config)
# ============= verbose msg =============
if config['DEBUG_FLAG']:
print("DEBUG: conf\n "+"\n ".join(["%s=%s"%(k,v) for k,v in config.items()]))
......@@ -550,4 +557,4 @@ def read_record(incoming_data):
########### MAIN ###########
if __name__ == "__main__":
# our app should be bound to an ip (cf stackoverflow.com/a/30329547/2489184)
app.run(host=config['COMEX_HOST'], port=config['COMEX_PORT'])
app.run(host=config['COMEX_HOST'], port=int(config['COMEX_PORT']))
......@@ -32,8 +32,8 @@ def home_path():
def read_config():
"""
reads all global config vars trying in order:
1) the config file $HOME/parametres_comex.ini
2) env variables of the same name
1) env variables of the same name
2) the config file $HOME/parametres_comex.ini
3) hard-coded default values
output is a simple dict
......@@ -56,18 +56,28 @@ def read_config():
default = citem['def']
is_bool = (type(default) == bool)
if section in ini and varname in ini[section]:
if is_bool:
out_dict[varname] = ini.getboolean(section, varname)
else:
out_dict[varname] = ini.get(section, varname)
elif varname in environ:
print("DEBUG: config for '%s'"%varname)
if varname in environ:
if is_bool:
out_dict[varname] = (environ[varname] == 'true')
else:
out_dict[varname] = environ[varname]
print("DEBUG: ok from env for '%s'"%varname)
elif section in ini and varname in ini[section]:
if is_bool:
out_dict[varname] = ini.getboolean(section, varname)
else:
out_dict[varname] = ini.get(section, varname)
print("DEBUG: ok from file for '%s'"%varname)
else:
out_dict[varname] = default
print("DEBUG: ok from default for '%s'"%varname)
# DEBUG FORCED
out_dict['DEBUG_FLAG'] = True
# also add our project home since we have it and we'll need it
out_dict['HOME'] = our_home
......
......@@ -9,34 +9,33 @@
- ../../data/shared_mysql_data:/var/lib/mysql
# in the future: external service (=> just remove doors_test & change DOORS_HOST and DOORS_PORT)
doors_test:
build: ./minidoors
image: minidoors:latest
ports:
- "32789:8989"
volumes:
- ../../../shared_minidoors_data:/root/.doors
# doors_test:
# build: ./minidoors
# image: minidoors:latest
# ports:
# - "32789:8989"
# volumes:
# - ../../../shared_minidoors_data:/root/.doors
comex_test:
ports:
- "32790:9090"
build: ./comex2_services
image: comex2_services:latest
image: comex2_services:testing
depends_on:
- comex_db_test
- doors_test
# - doors_test
links:
- comex_db_test:comex_db_backend
- doors_test:doors_backend
# - doors_test:doors_backend
# links the outside config parametres_comex.ini to the inside
# /!\ this erases the contained config with the outside one /!\
volumes:
- ../../config/:/comex2/config
# # moved from env vars to new config vars via volume config
- ../../config:/comex2/config
# moved from env vars to new config vars via volume config
# environment:
# - HOST=0.0.0.0 # script will bind server to this address
# - DEBUG_FLAG=false
# - DEBUG_FLAG=true
# - SQL_HOST=comex_db_backend # script will read/write sql to this host
# - DOORS_HOST=134.158.75.71
# - DOORS_PORT=80 # forwarded port we're accessing via ajax in tests
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment