From 466cf25da84d36366166857945f16e844f34ef81 Mon Sep 17 00:00:00 2001 From: myvesta <38690722+myvesta@users.noreply.github.com> Date: Fri, 12 Oct 2018 20:45:34 +0200 Subject: [PATCH] Bringing back default restart routine for nginx --- bin/v-restart-proxy | 70 ++++++++++++++++++++++++++------------------- 1 file changed, 41 insertions(+), 29 deletions(-) diff --git a/bin/v-restart-proxy b/bin/v-restart-proxy index 00758cc0..3e8df916 100755 --- a/bin/v-restart-proxy +++ b/bin/v-restart-proxy @@ -49,38 +49,50 @@ if [ -z "$PROXY_SYSTEM" ] || [ "$PROXY_SYSTEM" = 'remote' ]; then exit fi -# background restart -if [ "$1" = 'background' ]; then - # Restart system - sleep 15 - # rm /tmp/restart-nginx - service $PROXY_SYSTEM restart >/dev/null 2>&1 - if [ $? -ne 0 ]; then - send_email_report - check_result $E_RESTART "$PROXY_SYSTEM restart failed" - fi - - # Update restart queue - if [ -e "$VESTA/data/queue/restart.pipe" ]; then - sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe - fi +if [ -f "/usr/local/vesta/web/inc/nginx_proxy" ]; then + + # if vesta is behind default nginx, restart in background with 15 sec delay + # background restart + if [ "$1" = 'background' ]; then + # Restart system + sleep 15 + service $PROXY_SYSTEM restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + send_email_report + check_result $E_RESTART "$PROXY_SYSTEM restart failed" + fi + + # Update restart queue + if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe + fi + + exit; + fi + + # try to reload to get changes faster + service $PROXY_SYSTEM reload + + # send to background process + nohup $BIN/v-restart-proxy 'background' &>/dev/null & + +else + + # Default behaviour + # Restart system + service $PROXY_SYSTEM restart >/dev/null 2>&1 + if [ $? -ne 0 ]; then + send_email_report + check_result $E_RESTART "$PROXY_SYSTEM restart failed" + fi + + # Update restart queue + if [ -e "$VESTA/data/queue/restart.pipe" ]; then + sed -i "/$SCRIPT/d" $VESTA/data/queue/restart.pipe + fi - exit; fi -# if [ -f "/tmp/restart-nginx" ]; then -# exit; -# fi - -service $PROXY_SYSTEM reload -# if [ $? -ne 0 ]; then -# send_email_report -# check_result $E_RESTART "$PROXY_SYSTEM reload failed" -# fi - -# touch /tmp/restart-nginx -nohup $BIN/v-restart-proxy 'background' &>/dev/null & - #----------------------------------------------------------# # Vesta # #----------------------------------------------------------#