From b91eae630c13a2468f34008d9764360a7d3dd083 Mon Sep 17 00:00:00 2001 From: Alan Anselmo Date: Wed, 7 Feb 2024 11:14:12 -0300 Subject: [PATCH] Adds gunicorn to run main app --- .gitignore | 1 + configs/core.cfg.sample | 4 ++-- configs/gunicorn.conf.py | 27 +++++++++++++++++++++++++++ requirements.txt | 2 ++ 4 files changed, 32 insertions(+), 2 deletions(-) create mode 100644 configs/gunicorn.conf.py diff --git a/.gitignore b/.gitignore index acfff4e0..e83146e4 100644 --- a/.gitignore +++ b/.gitignore @@ -39,6 +39,7 @@ var/www/templates/header.html var/www/submitted var/www/server.crt var/www/server.key +var/www/gunicorn.conf.py # Local config configs/keys diff --git a/configs/core.cfg.sample b/configs/core.cfg.sample index bb9054fc..d34faf1e 100644 --- a/configs/core.cfg.sample +++ b/configs/core.cfg.sample @@ -40,7 +40,7 @@ ail_logs_syslog_level = ##### Notifications ###### [Notifications] -ail_domain = https://localhost:7000 +ail_domain = http://localhost:7000 sender = sender@example.com sender_host = smtp.example.com sender_port = 1337 @@ -57,7 +57,7 @@ sender_user = #Proxying requests to the app baseUrl = / #Host to bind to -host = 127.0.0.1 +host = 0.0.0.0 #Flask server port port = 7000 #Number of logs to display in the dashboard diff --git a/configs/gunicorn.conf.py b/configs/gunicorn.conf.py new file mode 100644 index 00000000..33cf60d5 --- /dev/null +++ b/configs/gunicorn.conf.py @@ -0,0 +1,27 @@ +import os +import sys + +sys.path.append('./modules/') +sys.path.append(os.environ['AIL_BIN']) + +from lib.ConfigLoader import ConfigLoader + + +config_loader = ConfigLoader() + +try: + host = config_loader.get_config_str("Flask", "host") +except Exception: + host = '0.0.0.0' + +try: + port = config_loader.get_config_int("Flask", "port") +except Exception: + port = 7000 + +bind = f"{host}:{port}" +workers = 2 +worker_class = 'sync' +timeout = 180 +loglevel = 'info' +limit_request_line = 0 \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 5fd7d7e3..cddff0ae 100644 --- a/requirements.txt +++ b/requirements.txt @@ -85,6 +85,8 @@ https://github.com/saffsd/langid.py/archive/master.zip requests +# WSGI server to run Flask app +gunicorn==20.1.0 ##### Old packages # texttable