Improve error message for all bdb docker entrypoint scripts

- If a mandatory variable is not specified, it will exit with the relevant
code and error message.
- For more verbosity, we will also echo the values for all the mandatory
variables.
This commit is contained in:
Muawia Khan
2017-08-16 13:15:24 +02:00
parent e7640feaec
commit d11c100ab5
5 changed files with 83 additions and 47 deletions

View File

@@ -29,20 +29,32 @@ bdb_ws_port=`printenv BIGCHAINDB_WS_PORT`
# sanity check
if [[ -z "${cluster_frontend_port}" || \
-z "${mongo_frontend_port}" || \
-z "${mongo_backend_host}" || \
-z "${mongo_backend_port}" || \
-z "${openresty_backend_port}" || \
-z "${openresty_backend_host}" || \
-z "${bdb_backend_host}" || \
-z "${bdb_api_port}" || \
-z "${bdb_ws_port}" || \
-z "${dns_server}" || \
-z "${health_check_port}" || \
-z "${cluster_fqdn}" ]]; then
echo "Invalid environment settings detected. Exiting!"
if [[ -z "${cluster_frontend_port:?Cluster frontend port not specified. Exiting!}" || \
-z "${mongo_frontend_port:?MongoDB frontend port not specified. Exiting!}" || \
-z "${mongo_backend_host:?MongoDB backend host not specified. Exiting!}" || \
-z "${mongo_backend_port:?MongoDB backend port not specified. Exiting!}" || \
-z "${openresty_backend_port:?OpenResty backend port not specified. Exiting!}" || \
-z "${openresty_backend_host:?OpenResty backend host not specified. Exiting!}" || \
-z "${bdb_backend_host:?BigchainDB backend host not specified. Exiting!}" || \
-z "${bdb_api_port:?BigchainDB API port not specified. Exiting!}" || \
-z "${bdb_ws_port:?BigchainDB WS port not specified. Exiting!}" || \
-z "${dns_server:?DNS server not specified. Exiting!}" || \
-z "${health_check_port:?Health check port not specified. Exiting!}" || \
-z "${cluster_fqdn:?Cluster FQDN not specified. Exiting!}" ]]; then
exit 1
else
echo CLUSTER_FQDN="$cluster_fqdn"
echo CLUSTER_FRONTEND_PORT="$cluster_frontend_port"
echo DNS_SERVER="$dns_server"
echo HEALTH_CHECK_PORT="$health_check_port"
echo MONGODB_FRONTEND_PORT="$mongo_frontend_port"
echo MONGODB_BACKEND_HOST="$mongo_backend_host"
echo MONGODB_BACKEND_PORT="$mongo_backend_port"
echo OPENRESTY_BACKEND_HOST="$openresty_backend_host"
echo OPENRESTY_BACKEND_PORT="$openresty_backend_port"
echo BIGCHAINDB_BACKEND_HOST="$bdb_backend_host"
echo BIGCHAINDB_API_PORT="$bdb_api_port"
echo BIGCHAINDB_WS_PORT="$bdb_ws_port"
fi
NGINX_CONF_FILE=/etc/nginx/nginx.conf