Skip to content

Commit

Permalink
Prepare for alpha9
Browse files Browse the repository at this point in the history
* Update documentation
* Update Docker files
* Add wsgi script
  • Loading branch information
Stefano Cossu committed Apr 3, 2018
1 parent efba20e commit b730533
Show file tree
Hide file tree
Showing 8 changed files with 118 additions and 92 deletions.
19 changes: 8 additions & 11 deletions README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,20 +31,17 @@ Dependencies
Installation steps
~~~~~~~~~~~~~~~~~~

1. Create a virtualenv in a project folder:
``virtualenv -p <python 3.5+ exec path> <virtualenv folder>``
2. Activate the virtualenv: ``source <path_to_virtualenv>/bin/activate``
3. Clone this repo:
``git clone https://github.com/scossu/lakesuperior.git``
4. ``cd`` into repo folder
5. Install dependencies: ``pip install -r requirements.txt``
6. Start your STOMP broker, e.g.: ``coilmq &``. If you have another
#. Create a virtualenv in a project folder:
``python3 -m venv <virtualenv folder>``
#. Activate the virtualenv: ``source <path_to_virtualenv>/bin/activate``
#. Install dependencies: ``pip install -r requirements.txt``
#. Start your STOMP broker, e.g.: ``coilmq &``. If you have another
queue manager listening to port 61613 you can either configure a
different port on the application configuration, or use the existing
message queue.
7. Run ``./lsup-admin bootstrap`` to initialize the binary and graph
stores
8. Run ``./fcrepo``.
#. Run ``lsup-admin bootstrap`` to initialize the binary and graph
stores.
#. Run ``fcrepo``.

Contributing
------------
Expand Down
5 changes: 3 additions & 2 deletions docker/docker_entrypoint
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,9 @@

mkdir -p /data/log /data/run /data/bootstrap
cp ./data/bootstrap/* /data/bootstrap
pip install -e .
coilmq &
if [ ! -d /data/ldpnr_store ] && [ ! -d /data/ldprs_store ]; then
echo yes | ./lsup-admin bootstrap
echo yes | lsup-admin bootstrap
fi
exec ./fcrepo
exec fcrepo
31 changes: 0 additions & 31 deletions docker/etc/gunicorn.py

This file was deleted.

24 changes: 24 additions & 0 deletions docker/etc/gunicorn.yml
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

34 changes: 11 additions & 23 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,26 +49,14 @@ Installation steps
#. Create a virtualenv in a project folder:
``python3 -m venv <virtualenv folder>``
#. Activate the virtualenv: ``source <path_to_virtualenv>/bin/activate``
#. Clone this repo:
``git clone https://github.com/scossu/lakesuperior.git``
#. ``cd`` into repo folder
#. Install dependencies: ``pip install -r requirements.txt``

- (Optional) For a development server, install additional dependencies:
``pip install -r requirements_dev.txt``. These include some heavyweight
packages needed for development and testing but not for regular operation.

#. Start your STOMP broker, e.g.: ``coilmq &``.

- If you have another
queue manager listening to port 61613 you can either configure a
different port on the application configuration, or use the existing
message queue.

#. Make sure that the ``lsup-admin`` and ``fcrepo`` files are executable.
#. Run ``./lsup-admin bootstrap`` to initialize the binary and graph
#. Start your STOMP broker, e.g.: ``coilmq &``. If you have another
queue manager listening to port 61613 you can either configure a
different port on the application configuration, or use the existing
message queue.
#. Run ``lsup-admin bootstrap`` to initialize the binary and graph
stores.
#. Run ``./fcrepo``.
#. Run ``fcrepo``.

Configuration
-------------
Expand All @@ -79,14 +67,14 @@ the ``data`` directory.

To change the default configuration you should:

1. Copy the ``etc.skeleton`` folder to a separate location
2. Set the configuration folder location in the environment:
#. Copy the ``etc.skeleton`` folder to a separate location
#. Set the configuration folder location in the environment:
``export FCREPO_CONFIG_DIR=<your config dir location>`` (you can add
this line at the end of your virtualenv ``activate`` script)
3. Configure the application
4. Bootstrap the app or copy the original data folders to the new
#. Configure the application
#. Bootstrap the app or copy the original data folders to the new
location if any loction options changed
5. (Re)start the server: ``./fcrepo``
#. (Re)start the server: ``./fcrepo``

The configuration options are documented in the files.

Expand Down
26 changes: 2 additions & 24 deletions requirements.txt
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 .
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@

setup(
name='lakesuperior',
version='1.0.0a9pre1',
version='1.0.0a91',

description='A Linked Data Platform repository sever.',
long_description=long_description,
Expand Down
69 changes: 69 additions & 0 deletions wsgi.py
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()

0 comments on commit b730533

Please sign in to comment.