Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Gunicorn WSGI Server #210

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ var/www/templates/header.html
var/www/submitted
var/www/server.crt
var/www/server.key
var/www/gunicorn.conf.py

# Local config
configs/keys
Expand Down
10 changes: 9 additions & 1 deletion bin/LAUNCH.sh
Original file line number Diff line number Diff line change
Expand Up @@ -466,12 +466,16 @@ function launch_scripts {
}

function launch_flask {
conf_dir="${AIL_HOME}/configs/"

if [[ ! $isflasked ]]; then
flask_dir=${AIL_FLASK}
screen -dmS "Flask_AIL"
sleep 0.1
echo -e $GREEN"\t* Launching Flask server"$DEFAULT
screen -S "Flask_AIL" -X screen -t "Flask_server" bash -c "cd $flask_dir; ls; ${ENV_PY} ./Flask_server.py; read x"
# screen -S "Flask_AIL" -X screen -t "Flask_server" bash -c "cd $flask_dir; ls; ${ENV_PY} ./Flask_server.py; read x"
screen -S "Flask_AIL" -X screen -t "Flask_server" \
bash -c "cd $flask_dir; ls; cp $conf_dir/gunicorn.conf.py .; gunicorn -c gunicorn.conf.py Flask_server:app; read x"
else
echo -e $RED"\t* A Flask screen is already launched"$DEFAULT
fi
Expand Down Expand Up @@ -517,6 +521,10 @@ function killall {
echo -e $GREEN"Gracefully closing Kvrocks servers"$DEFAULT
shutting_down_kvrocks;
fi
if [[ $isflasked ]]; then
echo -e $GREEN"Closing all gunicorn (Flask) servers"$DEFAULT
pkill gunicorn
fi
echo -e $GREEN"Killing all"$DEFAULT
kill $isredis $isardb $iskvrocks $islogged $is_ail_core $isscripted $isflasked $isfeeded $is_ail_2_ail
sleep 0.2
Expand Down
4 changes: 2 additions & 2 deletions configs/core.cfg.sample
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ ail_logs_syslog_level =

##### Notifications ######
[Notifications]
ail_domain = https://localhost:7000
ail_domain = http://localhost:7000
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please do not change core configs if not needed.

sender = [email protected]
sender_host = smtp.example.com
sender_port = 1337
Expand All @@ -62,7 +62,7 @@ sender_user =
#Proxying requests to the app
baseUrl = /
#Host to bind to
host = 127.0.0.1
host = 0.0.0.0
#Flask server port
port = 7000
#Number of logs to display in the dashboard
Expand Down
27 changes: 27 additions & 0 deletions configs/gunicorn.conf.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import os
import sys

sys.path.append('./modules/')
sys.path.append(os.environ['AIL_BIN'])

from lib.ConfigLoader import ConfigLoader


config_loader = ConfigLoader()

try:
host = config_loader.get_config_str("Flask", "host")
except Exception:
host = '0.0.0.0'

try:
port = config_loader.get_config_int("Flask", "port")
except Exception:
port = 7000

bind = f"{host}:{port}"
workers = 2
worker_class = 'sync'
timeout = 180
loglevel = 'info'
limit_request_line = 0
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,8 @@ https://github.com/saffsd/langid.py/archive/master.zip

requests

# WSGI server to run Flask app
gunicorn==20.1.0

##### Old packages
# texttable
Expand Down
Loading