1
0
mirror of https://github.com/donaldzou/WGDashboard.git synced 2024-06-30 22:50:14 +02:00

refactored

This commit is contained in:
Galonza Peter 2021-10-25 00:24:49 +03:00
parent c0fbf4dd0c
commit 94a0d5a0a4

View File

@ -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