1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-10-01 09:00:13 +02:00

fixed gunicorn start and added stop

This commit is contained in:
Galonza Peter 2021-10-18 02:40:08 +03:00
parent f0f9ac92e6
commit 898694b9be
2 changed files with 10 additions and 4 deletions

View File

@ -1183,6 +1183,8 @@ def run_dashboard():
Get host and port for web-server Get host and port for web-server
""" """
def get_host_bind(): def get_host_bind():
config = configparser.ConfigParser(strict=False)
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")

View File

@ -2,7 +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') environment=$(if [[ $ENVIRONMENT ]]; then echo $ENVIRONMENT; else echo 'develop'; fi)
dashes='------------------------------------------------------------' dashes='------------------------------------------------------------'
equals='============================================================' equals='============================================================'
help () { help () {
@ -51,7 +51,7 @@ check_wgd_status(){
} }
start_wgd () { start_wgd () {
if [[ $environment == 'production']]; then if [[ $environment == 'production' ]]; then
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,7 +59,7 @@ start_wgd () {
fi fi
d=$(date '+%Y%m%d%H%M%S') d=$(date '+%Y%m%d%H%M%S')
/usr/local/bin/gunicorn --access-logfile log/access_"$d".log \ /usr/local/bin/gunicorn --access-logfile log/access_"$d".log \
--error-logfile log/error_"$d".log 'dashboard.run_dashboard()' --error-logfile log/error_"$d".log 'dashboard:run_dashboard()'
printf "| Log files is under log/ |\n" printf "| Log files is under log/ |\n"
printf "%s\n" "$dashes" printf "%s\n" "$dashes"
else else
@ -76,7 +76,11 @@ start_wgd () {
} }
stop_wgd() { stop_wgd() {
kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')" if [[ $environment == 'production' ]]; then
kill $(cat ./gunicorn.pid)
else
kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')"
fi
} }
start_wgd_debug() { start_wgd_debug() {