diff --git a/src/wgd.sh b/src/wgd.sh index 2e034537..0e705798 100755 --- a/src/wgd.sh +++ b/src/wgd.sh @@ -57,21 +57,29 @@ check_wgd_status(){ fi } +gunicorn_start () { + 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') + if [[ $USER == root ]]; then + export PATH=$PATH:/usr/local/bin:$HOME/.local/bin + fi + 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" +} + +gunicorn_stop () { + kill $(cat ./gunicorn.pid) +} + 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') - if [[ $USER == root ]]; then - export PATH=$PATH:/usr/local/bin:$HOME/.local/bin - fi - 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" + gunicorn_start else printf "%s\n" "$dashes" printf "| Starting WGDashboard in the background. |\n" @@ -87,7 +95,7 @@ start_wgd () { stop_wgd() { if [[ $environment == 'production' ]]; then - kill $(cat ./gunicorn.pid) + gunicorn_stop else kill "$(ps aux | grep "[p]ython3 $app_name" | awk '{print $2}')" fi