mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-06 16:00:28 +01:00
Fixed Gunicorn global variable issue
This commit is contained in:
parent
461ae99dd8
commit
b64ba2ef16
@ -20,7 +20,7 @@ import bcrypt
|
|||||||
import ifcfg
|
import ifcfg
|
||||||
import psutil
|
import psutil
|
||||||
import pyotp
|
import pyotp
|
||||||
from flask import Flask, request, render_template, session
|
from flask import Flask, request, render_template, session, g
|
||||||
from json import JSONEncoder
|
from json import JSONEncoder
|
||||||
from flask_cors import CORS
|
from flask_cors import CORS
|
||||||
|
|
||||||
@ -1245,7 +1245,6 @@ def API_ValidateAuthentication():
|
|||||||
token = request.cookies.get("authToken") + ""
|
token = request.cookies.get("authToken") + ""
|
||||||
if token == "" or "username" not in session or session["username"] != token:
|
if token == "" or "username" not in session or session["username"] != token:
|
||||||
return ResponseObject(False, "Invalid authentication")
|
return ResponseObject(False, "Invalid authentication")
|
||||||
|
|
||||||
return ResponseObject(True)
|
return ResponseObject(True)
|
||||||
|
|
||||||
|
|
||||||
@ -1286,7 +1285,9 @@ def API_SignOut():
|
|||||||
|
|
||||||
@app.route('/api/getWireguardConfigurations', methods=["GET"])
|
@app.route('/api/getWireguardConfigurations', methods=["GET"])
|
||||||
def API_getWireguardConfigurations():
|
def API_getWireguardConfigurations():
|
||||||
WireguardConfigurations = _getConfigurationList()
|
# WireguardConfigurations = _getConfigurationList()
|
||||||
|
print("in request::::")
|
||||||
|
print(list(WireguardConfigurations.keys()))
|
||||||
return ResponseObject(data=[wc for wc in WireguardConfigurations.values()])
|
return ResponseObject(data=[wc for wc in WireguardConfigurations.values()])
|
||||||
|
|
||||||
|
|
||||||
@ -1838,18 +1839,20 @@ def gunicornConfig():
|
|||||||
_, app_port = DashboardConfig.GetConfig("Server", "app_port")
|
_, app_port = DashboardConfig.GetConfig("Server", "app_port")
|
||||||
return app_ip, app_port
|
return app_ip, app_port
|
||||||
|
|
||||||
# global sqldb, cursor, DashboardConfig, WireguardConfigurations, AllPeerJobs, JobLogger
|
|
||||||
|
|
||||||
sqldb = sqlite3.connect(os.path.join(CONFIGURATION_PATH, 'db', 'wgdashboard.db'), check_same_thread=False)
|
sqldb = sqlite3.connect(os.path.join(CONFIGURATION_PATH, 'db', 'wgdashboard.db'), check_same_thread=False)
|
||||||
sqldb.row_factory = sqlite3.Row
|
sqldb.row_factory = sqlite3.Row
|
||||||
cursor = sqldb.cursor()
|
cursor = sqldb.cursor()
|
||||||
DashboardConfig = DashboardConfig()
|
DashboardConfig = DashboardConfig()
|
||||||
WireguardConfigurations: dict[str, WireguardConfiguration] = {}
|
|
||||||
AllPeerJobs: PeerJobs = PeerJobs()
|
AllPeerJobs: PeerJobs = PeerJobs()
|
||||||
JobLogger: Logger = Logger()
|
JobLogger: Logger = Logger()
|
||||||
_, app_ip = DashboardConfig.GetConfig("Server", "app_ip")
|
_, app_ip = DashboardConfig.GetConfig("Server", "app_ip")
|
||||||
_, app_port = DashboardConfig.GetConfig("Server", "app_port")
|
_, app_port = DashboardConfig.GetConfig("Server", "app_port")
|
||||||
_, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path")
|
_, WG_CONF_PATH = DashboardConfig.GetConfig("Server", "wg_conf_path")
|
||||||
|
|
||||||
|
WireguardConfigurations: dict[str, WireguardConfiguration] = {}
|
||||||
WireguardConfigurations = _getConfigurationList()
|
WireguardConfigurations = _getConfigurationList()
|
||||||
bgThread = threading.Thread(target=backGroundThread)
|
bgThread = threading.Thread(target=backGroundThread)
|
||||||
bgThread.daemon = True
|
bgThread.daemon = True
|
||||||
|
@ -5,8 +5,8 @@ global sqldb, cursor, DashboardConfig, WireguardConfigurations, AllPeerJobs, Job
|
|||||||
app_host, app_port = dashboard.gunicornConfig()
|
app_host, app_port = dashboard.gunicornConfig()
|
||||||
|
|
||||||
worker_class = 'gthread'
|
worker_class = 'gthread'
|
||||||
workers = 4
|
workers = 1
|
||||||
threads = 2
|
threads = 1
|
||||||
bind = f"{app_host}:{app_port}"
|
bind = f"{app_host}:{app_port}"
|
||||||
daemon = True
|
daemon = True
|
||||||
pidfile = './gunicorn.pid'
|
pidfile = './gunicorn.pid'
|
Loading…
Reference in New Issue
Block a user