linux - force kill nginx if graceful one doesn't work

This commit is contained in:
florian 2023-08-07 14:42:13 +02:00
parent 6e6c08a716
commit bb6fd30739
No known key found for this signature in database
GPG key ID: 3D80806F12602A7C
3 changed files with 7 additions and 4 deletions

View file

@ -18,7 +18,7 @@ services:
- USE_GZIP=yes
- www.example.com_USE_UI=yes
- www.example.com_USE_REVERSE_PROXY=yes
- www.example.com_REVERSE_PROXY_URL=/admin
- www.example.com_REVERSE_PROXY_URL=/changeme
- www.example.com_REVERSE_PROXY_HOST=http://bw-ui:7000
- www.example.com_INTERCEPTED_ERROR_CODES=400 404 405 413 429 500 501 502 503 504
networks:

View file

@ -22,6 +22,11 @@ function stop_nginx() {
nginx -s stop
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while sending stop signal to nginx"
log "SYSTEMCTL" " " "Stopping nginx (force)..."
kill -TERM $(cat /var/run/bunkerweb/nginx.pid)
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while sending term signal to nginx"
fi
fi
fi
count=0
@ -113,7 +118,7 @@ function start() {
# Start nginx
log "SYSTEMCTL" "" "Starting temp nginx ..."
nginx
nginx -e /var/log/bunkerweb/error.log
if [ $? -ne 0 ] ; then
log "SYSTEMCTL" "❌" "Error while executing temp nginx"
exit 1

View file

@ -85,8 +85,6 @@ from logger import setup_logger # type: ignore
from Database import Database # type: ignore
from logging import getLogger
# logger = setup_logger("UI", getenv("LOG_LEVEL", "INFO"))
def stop_gunicorn():
p = Popen(["pgrep", "-f", "gunicorn"], stdout=PIPE)
out, _ = p.communicate()