From 898694b9befae3b53df831bbc116633c89887754 Mon Sep 17 00:00:00 2001 From: Galonza Peter Date: Mon, 18 Oct 2021 02:40:08 +0300 Subject: [PATCH] fixed gunicorn start and added stop --- src/dashboard.py | 2 ++ src/wgd.sh | 12 ++++++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/src/dashboard.py b/src/dashboard.py index 691ebb5..9f16f1e 100644 --- a/src/dashboard.py +++ b/src/dashboard.py @@ -1183,6 +1183,8 @@ def run_dashboard(): Get host and port for web-server """ def get_host_bind(): + config = configparser.ConfigParser(strict=False) + config.read('wg-dashboard.ini') app_ip = config.get("Server", "app_ip") app_port = config.get("Server", "app_port") diff --git a/src/wgd.sh b/src/wgd.sh index bba0828..d17f98f 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -2,7 +2,7 @@ app_name="dashboard.py" app_official_name="WGDashboard" -environment=$(if [[ $ENVIRONMENT ]] ; then echo $ENVIRONMENT else echo 'develop') +environment=$(if [[ $ENVIRONMENT ]]; then echo $ENVIRONMENT; else echo 'develop'; fi) dashes='------------------------------------------------------------' equals='============================================================' help () { @@ -51,7 +51,7 @@ check_wgd_status(){ } start_wgd () { - if [[ $environment == 'production']]; then + if [[ $environment == 'production' ]]; then printf "%s\n" "$dashes" printf "| Starting WGDashboard in the background. |\n" if [ ! -d "log" ] @@ -59,7 +59,7 @@ start_wgd () { 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()' + --error-logfile log/error_"$d".log 'dashboard:run_dashboard()' printf "| Log files is under log/ |\n" printf "%s\n" "$dashes" else @@ -76,7 +76,11 @@ start_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() {