100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps
Java asset-managementbuildingdashboarddataplatformdevice-managementedge-computingenergyenergy-managementenergy-monitorfleet-managementfleet-telematicsiotiot-applicationiot-platformmodbusmqttmqtt-brokerota-updaterules-enginesmartcity
Bug fix for proxy docker container
Rich Turner3386689096c1
diff --git a/proxy/entrypoint.sh b/proxy/entrypoint.shindex 4cfe6b775..586718be1 100644--- a/proxy/entrypoint.sh+++ b/proxy/entrypoint.sh@@ -30,9 +30,11 @@ export PROXY_LOGLEVEL=${PROXY_LOGLEVEL}# Assumeif [ ! -f ${CERT_FILE} ]; then+ INIT=trueHAPROXY_CONFIG="/etc/haproxy/haproxy-init.cfg"elseHAPROXY_CONFIG="/etc/haproxy/haproxy.cfg"+ INIT=falsefiHAPROXY_PID_FILE="/var/run/haproxy.pid"HAPROXY_CMD="haproxy -f ${HAPROXY_CONFIG} ${HAPROXY_USER_PARAMS} -D -p ${HAPROXY_PID_FILE}"@@ -71,10 +73,24 @@ function run_proxy {cron_auto_renewal_init+ # Cert file should now exist+ if [ "$INIT" = true ]; then+ restart+ fi++ log_info "Monitoring config file and cert $LE_WORK_DIR for changes..."+# Wait if config or certificates were changed, block this executionwhile inotifywait -q -r --exclude '\.git/' -e modify,create,delete,move,move_self $HAPROXY_CONFIG $LE_WORK_DIR; do+ log_info "Change detected..."+ restart+ log_info "Monitoring config file and cert $LE_WORK_DIR for changes..."+ done+}++function restart {if [ -f $HAPROXY_PID_FILE ]; then- log_info "Restarting HAProxy due to config changes..."+ log_info "Restarting HAProxy..."# Wait for the certificate to be present before restarting or might interrupt cert generation/renewallog_info "Waiting for certificate '${CERT_FILE}' to exist..."@@ -84,9 +100,12 @@ function run_proxy {HAPROXY_CMD="haproxy -f ${HAPROXY_CONFIG} ${HAPROXY_USER_PARAMS} -D -p ${HAPROXY_PID_FILE}"HAPROXY_CHECK_CONFIG_CMD="haproxy -f ${HAPROXY_CONFIG} -c"+ log_info "HAPROXY_CONFIG: ${HAPROXY_CONFIG}"+ log_info "HAPROXY_CMD: ${HAPROXY_CMD}"+if $HAPROXY_CHECK_CONFIG_CMD; then$HAPROXY_CMD -sf $(cat $HAPROXY_PID_FILE)- log_info "HAProxy restarted, pid $(cat $HAPROXY_PID_FILE)." && log+ log_info "HAProxy restarted, pid $(cat $HAPROXY_PID_FILE)."elselog_info "HAProxy config invalid, not restarting..."fi@@ -94,7 +113,6 @@ function run_proxy {log_error"Error: no $HAPROXY_PID_FILE present, HAProxy exited."breakfi- done}function add {@@ -355,11 +373,13 @@ function cron_auto_renewal {# If not defined, the default is dailyCRON_TIME=${CRON_TIME:-@daily}log_info "Scheduling cron job with execution time ${CRON_TIME}"- log_info "${CRON_TIME} root /entrypoint.sh auto-renew >> /var/log/cron.log 2>&1" > /etc/cron.d/letsencrypt+ echo "${CRON_TIME} root /entrypoint.sh auto-renew >> /var/log/cron.log 2>&1" > /etc/cron.d/letsencrypt# Start crond if not runningif ! [ -f /var/run/crond.pid ]; then+ log_info "CRON daemon starting..."crond+ log_info "CRON daemon started"fi}