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

Updated gunicorn configuration. Closes #23. Also impacts #5 and #24. #52

Merged
merged 5 commits into from
Mar 18, 2016
Merged
Changes from 1 commit
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
Prev Previous commit
Next Next commit
Added configuration files for gunicorn and supervisor
Pieter De Praetere committed Mar 18, 2016

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature.
commit 5c6dfc080c4d0e24b2d2fc4c6716a32f77d39fd9
6 changes: 3 additions & 3 deletions gunicorn/resolver.cfg → gunicorn/resolver.cfg.example
Original file line number Diff line number Diff line change
@@ -4,8 +4,8 @@ import multiprocessing
# See http://docs.gunicorn.org/en/latest/settings.html

# Address to bind to. By default it is localhost.
proxy_name = 'resolver.app' # The address to bind to.
proxy_port = '8080' # The port to bind to
proxy_name = '127.20.0.1' # The address to bind to.
proxy_port = '8080' # The port to bind to.
bind = '{0}:{1}'.format(proxy_name, proxy_port)

# Workers
@@ -14,6 +14,6 @@ workers = multiprocessing.cpu_count() * 2 + 1

# Timeout
# As the resolver sometimes parses large files, we set this to a minimum
# of 900 seconds (15 minutes). Increase if you get Proxy errors and timeouts.
# of 900 seconds (15 minutes). Increase if you get proxy errors and timeouts.
timeout = 900
graceful_timeout = 900
2 changes: 1 addition & 1 deletion run_gunicorn.sh
Original file line number Diff line number Diff line change
@@ -4,4 +4,4 @@ if [ -d "venv" ]; then
source venv/bin/activate
fi

exec gunicorn -c /vagrant/gunicorn/resolver.cfg resolver:wsgi_app
exec gunicorn -c gunicorn/resolver.cfg resolver:wsgi_app
6 changes: 6 additions & 0 deletions supervisor/resolver.cfg.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
##
# Configuration settings for supervisor
##
RESOLVER_USER="user"
RESOLVER_NAME="resolver_name"
RESOLVER_DIR="resolver_dir"
39 changes: 29 additions & 10 deletions supervisor/run_server.sh
Original file line number Diff line number Diff line change
@@ -1,14 +1,25 @@
#!/bin/bash

if [ "$1" == "" -o "$2" == "" -o "$3" == "" -o "$4" == "" ]; then
if [ "$1" != "" -a "$2" != "" -a "$3" == "" -a "$4" == "" ]; then
# After v2.0.0, we changed to way this script is run. To save something
# of backward compatibility, we accept calls where either two arguments are given
# which we assume to be the resolver_name and the c_dir (new way)
# or when 4 arguments are given (old way)
# We ignore the configuration file if that happens
c_dir="$2"
server_name="$1"
else
if [ "$1" == "" -o "$2" == "" -o "$3" == "" -o "$4" == "" ]; then
echo "Error: parameter missing. Invoke as $0 [server_name] [proxy_name] [port] [resolver-dir]"
c_dir="$4"
server_name="$1"
proxy_name="$2"
port="$3"
exit 1
fi
fi


c_dir="$4"
server_name="$1"
proxy_name="$2"
port="$3"

if [ ! -d "$c_dir" ]; then
echo "Error: resolver directory $c_dir does not exist!"
@@ -23,12 +34,20 @@ if [ ! -f "$c_dir""/""resolver.cfg" ]; then
fi

if [ ! -d "$c_dir""/""$server_name""/bin" ]; then
virtualenv "$server_name"
. "$server_name""/bin/activate"
virtualenv "$server_name"
. "$server_name""/bin/activate"
else
. "$server_name""/bin/activate"
. "$server_name""/bin/activate"
fi

if "$proxy_name" != "" ]; then
exec gunicorn -w 4 -b "$proxy_name"":""$port" resolver:wsgi_app --timeout 900 --graceful-timeout 900
else
exec gunicorn -c "$c_dir/gunicorn/resolver.cfg" resolver:wsgi_app
fi



#exec gunicorn -w 4 -b 127.0.0.1:8080 resolver:wsgi_app
exec gunicorn -w 4 -b "$proxy_name"":""$port" resolver:wsgi_app --timeout 900 --graceful-timeout 900
exit 0

exit 0
17 changes: 3 additions & 14 deletions supervisor/start_server.sh
Original file line number Diff line number Diff line change
@@ -1,22 +1,11 @@
#!/bin/bash

##
# Configuration settings (EDIT THESE)
##
RESOLVER_USER="user"
RESOLVER_NAME="resolver_name"
PROXY_NAME="proxy_name"
PROXY_PORT="proxy_port"
RESOLVER_DIR="resolver_dir"

##
# Application
# DO NOT EDIT ANYTHING BELOW THIS LINE
##############################################################################
# Get the configuration options
source supervisor/resolver.cfg

if [ "$(id -un)" != "$RESOLVER_USER" ]; then
echo "This script must be run as the $RESOLVER_USER user."
exit 1
fi
exec supervisor/run_server.sh "$RESOLVER_NAME" "$PROXY_NAME" "$PROXY_PORT" "$RESOLVER_DIR"
exec supervisor/run_server.sh "$RESOLVER_NAME" "$RESOLVER_DIR"
exit 0