2024-12-12 16:25:54 +08:00
|
|
|
import os.path
|
|
|
|
|
|
|
|
import dashboard, configparser
|
2024-08-04 19:45:28 -04:00
|
|
|
from datetime import datetime
|
2024-08-05 15:39:11 -04:00
|
|
|
|
2024-08-02 21:48:42 -04:00
|
|
|
global sqldb, cursor, DashboardConfig, WireguardConfigurations, AllPeerJobs, JobLogger
|
2024-06-18 03:40:25 +08:00
|
|
|
app_host, app_port = dashboard.gunicornConfig()
|
2024-08-04 19:45:28 -04:00
|
|
|
date = datetime.today().strftime('%Y_%m_%d_%H_%M_%S')
|
|
|
|
|
2024-08-05 15:39:11 -04:00
|
|
|
def post_worker_init(worker):
|
|
|
|
dashboard.startThreads()
|
|
|
|
|
2021-10-24 23:41:06 +03:00
|
|
|
worker_class = 'gthread'
|
2024-08-03 13:25:57 -04:00
|
|
|
workers = 1
|
|
|
|
threads = 1
|
2021-10-18 02:24:09 +03:00
|
|
|
bind = f"{app_host}:{app_port}"
|
|
|
|
daemon = True
|
2024-08-04 18:59:45 -04:00
|
|
|
pidfile = './gunicorn.pid'
|
2024-08-04 19:32:16 -04:00
|
|
|
wsgi_app = "dashboard:app"
|
2024-08-04 20:23:41 -04:00
|
|
|
accesslog = f"./log/access_{date}.log"
|
2024-08-04 19:35:59 -04:00
|
|
|
log_level = "debug"
|
|
|
|
capture_output = True
|
2024-08-04 20:23:41 -04:00
|
|
|
errorlog = f"./log/error_{date}.log"
|
2024-12-12 16:25:54 +08:00
|
|
|
|
|
|
|
if os.path.exists("./ssl.ini"):
|
|
|
|
sslConfig = configparser.ConfigParser()
|
|
|
|
sslConfig.read_file(open('./ssl.ini', 'r'))
|
|
|
|
if sslConfig.has_section('SSL'):
|
|
|
|
cert = sslConfig.get('SSL', 'certificate_path')
|
|
|
|
pem = sslConfig.get('SSL', 'private_key_path')
|
|
|
|
if cert and pem and len(cert) > 0 and len(pem) > 0:
|
|
|
|
certfile = cert
|
|
|
|
keyfile = pem
|
|
|
|
print(f"[WGDashboard] HTTPS enable", flush=True)
|
|
|
|
|
|
|
|
|
2024-08-04 20:13:17 -04:00
|
|
|
print(f"[WGDashboard] WGDashboard w/ Gunicorn will be running on {bind}", flush=True)
|
2024-08-04 20:24:31 -04:00
|
|
|
print(f"[WGDashboard] Access log file is at {accesslog}", flush=True)
|
|
|
|
print(f"[WGDashboard] Error log file is at {errorlog}", flush=True)
|