-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Update documentation * Update Docker files * Add wsgi script
- Loading branch information
Stefano Cossu
committed
Apr 3, 2018
1 parent
efba20e
commit b730533
Showing
8 changed files
with
118 additions
and
92 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
# Set up main GUnicorn options. | ||
# See: http://docs.gunicorn.org/en/stable/settings.html | ||
|
||
# Commented values are the application defaults. | ||
|
||
# Directory where the WSGI server data are stored. | ||
data_dir: 'data' | ||
|
||
# Set app_mode to either 'prod', 'test' or 'dev'. | ||
# 'prod' is normal running mode. 'test' is used for running test suites. | ||
# 'dev' is similar to normal mode but with reload and debug enabled. | ||
app_mode: 'dev' | ||
|
||
#listen_addr: '0.0.0.0' | ||
#listen_port: 8000 | ||
#workers: 4 | ||
#worker_class: 'gevent' | ||
#max_requests: 512 | ||
|
||
#user: '' | ||
#group: '' | ||
|
||
#preload_app: True | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,24 +1,2 @@ | ||
CoilMQ==1.0.1 | ||
Flask==0.12.2 | ||
HiYaPyCo==0.4.11 | ||
Pillow==4.3.0 | ||
PyYAML==3.12 | ||
arrow==0.10.0 | ||
click-log==0.2.1 | ||
click==6.7 | ||
gevent==1.2.2 | ||
gunicorn==19.7.1 | ||
lmdb==0.93 | ||
numpy==1.14.1 | ||
pytest-flask==0.10.0 | ||
pytest==3.2.2 | ||
rdflib==4.2.2 | ||
requests-toolbelt==0.8.0 | ||
requests==2.18.4 | ||
sphinx-rtd-theme==0.2.4 | ||
stomp.py==4.1.20 | ||
wheel==0.30.0a0 | ||
|
||
# Uncomment this and remove all above when the project will be in PyPI. | ||
#--index-url https://pypi.python.org/lakesuperior/ | ||
#-e . | ||
--index-url https://pypi.python.org/lakesuperior/ | ||
-e . |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import multiprocessing | ||
import yaml | ||
|
||
from os import environ, path | ||
|
||
import gunicorn.app.base | ||
|
||
from server import fcrepo | ||
|
||
|
||
default_config_dir = '{}/etc.defaults'.format( | ||
path.dirname(path.abspath(__file__))) | ||
config_dir = environ.get('FCREPO_CONFIG_DIR', default_config_dir) | ||
config_file = '{}/gunicorn.yml'.format(config_dir) | ||
|
||
with open(config_file, 'r') as fh: | ||
config = yaml.load(fh, yaml.SafeLoader) | ||
|
||
listen_addr = config.get('listen_addr', '0.0.0.0') | ||
listen_port = config.get('listen_port', 8000) | ||
preload_app = config.get('preload_app', True) | ||
app_mode = config.get('app_mode', 'prod') | ||
data_dir = path.realpath(config.get('data_dir')) | ||
|
||
def default_workers(): | ||
return (multiprocessing.cpu_count() * 2) + 1 | ||
|
||
options = { | ||
'bind': '{}:{}'.format(listen_addr, listen_port), | ||
'workers': config.get('workers', default_workers()), | ||
'worker_class': config.get('worker_class', 'gevent'), | ||
'max_requests': config.get('max_requests', 512), | ||
|
||
'user': config.get('user'), | ||
'group': config.get('group'), | ||
|
||
'raw_env': 'APP_MODE={}'.format(app_mode), | ||
|
||
'preload_app': preload_app, | ||
'daemon': app_mode=='prod', | ||
'reload': app_mode=='dev' and not preload_app, | ||
|
||
'pidfile': '{}/run/fcrepo.pid'.format(data_dir), | ||
'accesslog': '{}/log/gunicorn-access.log'.format(data_dir), | ||
'errorlog': '{}/log/gunicorn-error.log'.format(data_dir), | ||
} | ||
|
||
|
||
class WsgiApp(gunicorn.app.base.BaseApplication): | ||
|
||
def __init__(self, app, options={}): | ||
self.options = options | ||
self.application = app | ||
super(WsgiApp, self).__init__() | ||
|
||
def load_config(self): | ||
for key, value in self.options.items(): | ||
self.cfg.set(key.lower(), value) | ||
|
||
def load(self): | ||
return self.application | ||
|
||
|
||
def run(): | ||
WsgiApp(fcrepo, options).run() | ||
|
||
|
||
if __name__ == '__main__': | ||
run() |