Update gunicorn to use a config file as well + Fix headers error + Small fixes

This commit is contained in:
Théophile Diot 2023-05-31 14:18:15 -04:00
parent a424d59b1b
commit 5e237d0d03
No known key found for this signature in database
GPG Key ID: E752C80DB72BB014
5 changed files with 33 additions and 10 deletions

View File

@ -79,4 +79,4 @@ USER ui:ui
HEALTHCHECK --interval=10s --timeout=10s --start-period=30s --retries=6 CMD /usr/share/bunkerweb/helpers/healthcheck-ui.sh
ENV PYTHONPATH /usr/share/bunkerweb/deps/python
CMD ["python3", "-m", "gunicorn", "--user", "ui", "--group", "ui", "main:app", "--worker-class", "gevent", "--bind", "0.0.0.0:7000", "--graceful-timeout", "0", "--access-logfile", "-", "--error-logfile", "-"]
CMD ["python3", "-m", "gunicorn", "--config", "/usr/share/bunkerweb/ui/gunicorn.conf.py", "--bind", "0.0.0.0:7000"]

23
src/ui/gunicorn.conf.py Normal file
View File

@ -0,0 +1,23 @@
from os import sep
from os.path import join
wsgi_app = "main:app"
proc_name = "bunkerweb-ui"
accesslog = "-"
access_log_format = (
'%({x-forwarded-for}i)s %(l)s %(u)s %(t)s "%(r)s" %(s)s %(b)s "%(f)s" "%(a)s"'
)
errorlog = "-"
preload_app = True
pidfile = join(sep, "var", "tmp", "bunkerweb", "ui.pid")
user = "ui"
group = "ui"
secure_scheme_headers = {
"X-FORWARDED-PROTOCOL": "https",
"X-FORWARDED-PROTO": "https",
"X-FORWARDED-SSL": "on",
}
forwarded_allow_ips = "*"
proxy_allow_ips = "*"
worker_class = "gevent"
graceful_timeout = 0

View File

@ -18,6 +18,10 @@ for deps_path in [
if deps_path not in sys_path:
sys_path.append(deps_path)
from gevent import monkey
monkey.patch_all()
from bs4 import BeautifulSoup
from copy import deepcopy
from datetime import datetime, timedelta, timezone
@ -93,8 +97,8 @@ def stop_gunicorn():
def stop(status, stop=True):
Path(sep, "var", "tmp", "bunkerweb", "ui.pid").unlink(exist_ok=True)
Path(sep, "var", "tmp", "bunkerweb", "ui.healthy").unlink(exist_ok=True)
Path(sep, "var", "tmp", "bunkerweb", "ui.pid").unlink(missing_ok=True)
Path(sep, "var", "tmp", "bunkerweb", "ui.healthy").unlink(missing_ok=True)
if stop is True:
stop_gunicorn()
_exit(status)
@ -110,11 +114,6 @@ signal(SIGINT, handle_stop)
signal(SIGTERM, handle_stop)
sbin_nginx_path = Path(sep, "usr", "sbin", "nginx")
pid_file = Path(sep, "var", "tmp", "bunkerweb", "ui.pid")
if not pid_file.is_file():
pid_file.write_text(str(getpid()))
del pid_file
# Flask app
app = Flask(

View File

@ -135,7 +135,7 @@ class Instances:
instances.append(
Instance(
instance._id,
instance.id,
instance.name,
instance.name,
"container",
@ -183,7 +183,7 @@ class Instances:
instances.append(
Instance(
instance._id,
instance.id,
instance.name,
instance.name,
"service",

View File

@ -40,6 +40,7 @@
logoEl.classList.toggle("scale-105");
}, 300);
const reloading = setInterval(check_reloading, 2000);
check_reloading();
async function check_reloading() {
const controller = new AbortController();