Skip to content

Commit

Permalink
Packaging (#40)
Browse files Browse the repository at this point in the history
Restructure many files for distro inclusion.

* Add assets and HTML templates
* Move utils under lakesuperior package
* Move etc.defaults into lakesuperior package.
* Gunicorn gets default config dir from config parser.
* More reliable base directory for configuration.
* Change config dir in Dockerfile.
  • Loading branch information
scossu committed Apr 4, 2018
1 parent ee98f65 commit 14bcd76
Show file tree
Hide file tree
Showing 15 changed files with 26 additions and 16 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ RUN mkdir -p /usr/local /data
WORKDIR /usr/local
ADD . lakesuperior
WORKDIR /usr/local/lakesuperior
RUN cp ./docker/etc/* ./etc.defaults/
RUN pip install -e .
RUN cp ./docker/etc/* ./lakesuperior/etc.defaults/
CMD ./docker/docker_entrypoint
EXPOSE 8000
HEALTHCHECK --interval=30s --timeout=5s \
Expand Down
1 change: 1 addition & 0 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
include README.rst
include LICENSE
graft lakesuperior/endpoints/templates
graft lakesuperior/etc.defaults
4 changes: 2 additions & 2 deletions docker/etc/gunicorn.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@
# Commented values are the application defaults.

# Directory where the WSGI server data are stored.
data_dir: 'data'
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'
app_mode: 'prod'

#listen_addr: '0.0.0.0'
#listen_port: 8000
Expand Down
3 changes: 1 addition & 2 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,7 @@

from unittest.mock import MagicMock

#sys.path.insert(0, os.path.abspath('../'))
sys.path.append(os.path.abspath('../'))
#sys.path.append(os.path.abspath('../'))

class MockModule(MagicMock):
@classmethod
Expand Down
4 changes: 2 additions & 2 deletions docs/setup.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,14 +79,14 @@ the ``data`` directory.

To change the default configuration you should:

#. Copy the ``etc.skeleton`` folder to a separate location
#. Copy the ``etc.default`` 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)
#. Configure the application
#. Bootstrap the app or copy the original data folders to the new
location if any loction options changed
#. (Re)start the server: ``./fcrepo``
#. (Re)start the server: ``fcrepo``

The configuration options are documented in the files.

Expand Down
18 changes: 16 additions & 2 deletions lakesuperior/config_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,21 @@
import hiyapyco
import yaml

import lakesuperior


default_config_dir = environ.get('FCREPO_CONFIG_DIR', path.dirname(
path.abspath(lakesuperior.__file__)) + '/etc.defaults')
"""
Default configuration directory.
This value falls back to the provided ``etc.defaults`` directory if the
``FCREPO_CONFIG_DIR`` environment variable is not set.
This value can still be overridden by custom applications by passing the
``config_dir`` value to :func:`parse_config` explicitly.
"""


def parse_config(config_dir=None):
"""
Expand All @@ -30,8 +45,7 @@ def parse_config(config_dir=None):
)

if not config_dir:
config_dir = environ.get('FCREPO_CONFIG_DIR', path.dirname(
path.dirname(path.abspath(__file__))) + '/etc.defaults')
config_dir = default_config_dir

# This will hold a dict of all configuration values.
_config = {}
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
6 changes: 2 additions & 4 deletions lakesuperior/wsgi.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,10 @@
import gunicorn.app.base

from lakesuperior.server import fcrepo
from lakesuperior.config_parser import default_config_dir


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)
config_file = '{}/gunicorn.yml'.format(default_config_dir)

with open(config_file, 'r') as fh:
config = yaml.load(fh, yaml.SafeLoader)
Expand Down
4 changes: 1 addition & 3 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@

setup(
name='lakesuperior',
version='1.0.0a98',
version='1.0.0a99',

description='A Linked Data Platform repository sever.',
long_description=long_description,
Expand Down Expand Up @@ -104,10 +104,8 @@
include_package_data=True,
#extras_require={},
#package_data={
# 'endpoints': ['templates/*'],
#},
data_files=[
('etc', glob('etc.defaults/*.yml')),
('data/bootstrap', glob('data/bootstrap/*')),
('data/ldpnr_store', ['data/ldpnr_store/.keep']),
('data/ldprs_store', ['data/ldprs_store/.keep']),
Expand Down

0 comments on commit 14bcd76

Please sign in to comment.