mirror of
https://github.com/donaldzou/WGDashboard.git
synced 2024-11-22 15:20:09 +01:00
added gunicorn start
This commit is contained in:
parent
ea0229a8ab
commit
f0f9ac92e6
@ -1161,8 +1161,12 @@ def check_update():
|
|||||||
else:
|
else:
|
||||||
return "true"
|
return "true"
|
||||||
|
|
||||||
def run_wsgi():
|
"""
|
||||||
|
Configure DashBoard before start web-server
|
||||||
|
"""
|
||||||
|
def run_dashboard():
|
||||||
init_dashboard()
|
init_dashboard()
|
||||||
|
update = check_update()
|
||||||
global config
|
global config
|
||||||
config = configparser.ConfigParser(strict=False)
|
config = configparser.ConfigParser(strict=False)
|
||||||
config.read('wg-dashboard.ini')
|
config.read('wg-dashboard.ini')
|
||||||
@ -1175,13 +1179,15 @@ def run_wsgi():
|
|||||||
config.clear()
|
config.clear()
|
||||||
return app
|
return app
|
||||||
|
|
||||||
if __name__ == "__main__":
|
"""
|
||||||
init_dashboard()
|
Get host and port for web-server
|
||||||
update = check_update()
|
"""
|
||||||
config = configparser.ConfigParser(strict=False)
|
def get_host_bind():
|
||||||
config.read('wg-dashboard.ini')
|
|
||||||
app_ip = config.get("Server", "app_ip")
|
app_ip = config.get("Server", "app_ip")
|
||||||
app_port = config.get("Server", "app_port")
|
app_port = config.get("Server", "app_port")
|
||||||
wg_conf_path = config.get("Server", "wg_conf_path")
|
|
||||||
config.clear()
|
return app_ip, app_port
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
run_dashboard()
|
||||||
app.run(host=app_ip, debug=False, port=app_port)
|
app.run(host=app_ip, debug=False, port=app_port)
|
6
src/gunicorn.conf.py
Normal file
6
src/gunicorn.conf.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
import dashboard
|
||||||
|
|
||||||
|
app_host, app_port = dashboard.get_host_bind()
|
||||||
|
bind = f"{app_host}:{app_port}"
|
||||||
|
daemon = True
|
||||||
|
pidfile = './gunicorn.pid'
|
14
src/wgd.sh
14
src/wgd.sh
@ -2,6 +2,7 @@
|
|||||||
|
|
||||||
app_name="dashboard.py"
|
app_name="dashboard.py"
|
||||||
app_official_name="WGDashboard"
|
app_official_name="WGDashboard"
|
||||||
|
environment=$(if [[ $ENVIRONMENT ]] ; then echo $ENVIRONMENT else echo 'develop')
|
||||||
dashes='------------------------------------------------------------'
|
dashes='------------------------------------------------------------'
|
||||||
equals='============================================================'
|
equals='============================================================'
|
||||||
help () {
|
help () {
|
||||||
@ -50,6 +51,18 @@ check_wgd_status(){
|
|||||||
}
|
}
|
||||||
|
|
||||||
start_wgd () {
|
start_wgd () {
|
||||||
|
if [[ $environment == 'production']]; then
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
|
printf "| Starting WGDashboard in the background. |\n"
|
||||||
|
if [ ! -d "log" ]
|
||||||
|
then mkdir "log"
|
||||||
|
fi
|
||||||
|
d=$(date '+%Y%m%d%H%M%S')
|
||||||
|
/usr/local/bin/gunicorn --access-logfile log/access_"$d".log \
|
||||||
|
--error-logfile log/error_"$d".log 'dashboard.run_dashboard()'
|
||||||
|
printf "| Log files is under log/ |\n"
|
||||||
|
printf "%s\n" "$dashes"
|
||||||
|
else
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
printf "| Starting WGDashboard in the background. |\n"
|
printf "| Starting WGDashboard in the background. |\n"
|
||||||
if [ ! -d "log" ]
|
if [ ! -d "log" ]
|
||||||
@ -59,6 +72,7 @@ start_wgd () {
|
|||||||
python3 "$app_name" > log/"$d".txt 2>&1 &
|
python3 "$app_name" > log/"$d".txt 2>&1 &
|
||||||
printf "| Log files is under log/ |\n"
|
printf "| Log files is under log/ |\n"
|
||||||
printf "%s\n" "$dashes"
|
printf "%s\n" "$dashes"
|
||||||
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
stop_wgd() {
|
stop_wgd() {
|
||||||
|
@ -1,6 +0,0 @@
|
|||||||
import dashboard
|
|
||||||
|
|
||||||
|
|
||||||
if __name__ in "__main__":
|
|
||||||
dashboard.run_wsgi()
|
|
||||||
dashboard.app.run()
|
|
Loading…
Reference in New Issue
Block a user