better dynamic reload script
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
**Nginx base image with additional plugins and custom compiled**
|
**Nginx base image with additional plugins and custom compiled**
|
||||||
|
|
||||||
# SYNOPSIS
|
# SYNOPSIS
|
||||||
What can I do with this? This image will serve as a base for nginx related images that need a high-performance webserver. It can also be used stand alone as a webserver or reverse proxy.
|
What can I do with this? This image will serve as a base for nginx related images that need a high-performance webserver. It can also be used stand alone as a webserver or reverse proxy. It will automatically reload on config changes if configured.
|
||||||
|
|
||||||
# VOLUMES
|
# VOLUMES
|
||||||
* **/nginx/etc** - Directory of vHost config, must end in *.conf (set in /etc/nginx/nginx.conf)
|
* **/nginx/etc** - Directory of vHost config, must end in *.conf (set in /etc/nginx/nginx.conf)
|
||||||
|
25
rootfs/usr/local/bin/dynamic_reload.sh
Normal file
25
rootfs/usr/local/bin/dynamic_reload.sh
Normal file
@@ -0,0 +1,25 @@
|
|||||||
|
#!/bin/ash
|
||||||
|
elevenLogJSON info "reloading config"
|
||||||
|
NGINX_DYNAMIC_RELOAD_LOG=${APP_ROOT}/run/reload.log
|
||||||
|
nginx -t &> ${NGINX_DYNAMIC_RELOAD_LOG}
|
||||||
|
|
||||||
|
while read -r LINE; do
|
||||||
|
if echo "${LINE}" | grep -q "nginx: "; then
|
||||||
|
if echo "${LINE}" | grep -q "\[warn\]"; then
|
||||||
|
LINE=$(echo ${LINE} | sed 's/nginx: \[warn\] //')
|
||||||
|
elevenLogJSON warning "${LINE}"
|
||||||
|
fi
|
||||||
|
|
||||||
|
if echo "${LINE}" | grep -q "\[emerg\]"; then
|
||||||
|
LINE=$(echo ${LINE} | sed 's/nginx: \[emerg\] //')
|
||||||
|
elevenLogJSON error "${LINE}"
|
||||||
|
fi
|
||||||
|
fi
|
||||||
|
done < ${NGINX_DYNAMIC_RELOAD_LOG}
|
||||||
|
|
||||||
|
if cat ${NGINX_DYNAMIC_RELOAD_LOG} | grep -q "test is successful"; then
|
||||||
|
nginx -s reload
|
||||||
|
elevenLogJSON info "config reloaded"
|
||||||
|
else
|
||||||
|
elevenLogJSON error "config reload failed!"
|
||||||
|
fi
|
@@ -10,7 +10,7 @@
|
|||||||
if [ -z "${1}" ]; then
|
if [ -z "${1}" ]; then
|
||||||
if [ ! -z ${NGINX_DYNAMIC_RELOAD} ]; then
|
if [ ! -z ${NGINX_DYNAMIC_RELOAD} ]; then
|
||||||
elevenLogJSON info "enable dynamic reload"
|
elevenLogJSON info "enable dynamic reload"
|
||||||
/sbin/inotifyd /usr/local/bin/io.sh ${APP_ROOT}/etc:cdnym &
|
/sbin/inotifyd /usr/local/bin/dynamic_reload.sh ${APP_ROOT}/etc:cdnym &
|
||||||
fi
|
fi
|
||||||
|
|
||||||
elevenLogJSON info "starting ${APP_NAME} (${APP_VERSION})"
|
elevenLogJSON info "starting ${APP_NAME} (${APP_VERSION})"
|
||||||
|
@@ -1,16 +0,0 @@
|
|||||||
#!/bin/ash
|
|
||||||
RELOAD_LOG=${APP_ROOT}/run/reload.log
|
|
||||||
nginx -tq &> ${RELOAD_LOG}
|
|
||||||
elevenLogJSON info "change in config files detected"
|
|
||||||
if cat ${RELOAD_LOG} | grep -q "nginx.conf test failed"; then
|
|
||||||
elevenLogJSON info "error in configuration files found"
|
|
||||||
cat ${RELOAD_LOG}
|
|
||||||
else
|
|
||||||
if cat ${RELOAD_LOG} | grep -q "nginx.conf test is successful"; then
|
|
||||||
elevenLogJSON info "reload nginx with config changes"
|
|
||||||
nginx -s reload
|
|
||||||
else
|
|
||||||
elevenLogJSON info "error in configuration files found"
|
|
||||||
cat ${RELOAD_LOG}
|
|
||||||
fi
|
|
||||||
fi
|
|
Reference in New Issue
Block a user