Browse Source

Merge branch 'master' of https://github.com/scossu/lakesuperior

Stefano Cossu 6 years ago
parent
commit
9cce538b97

+ 1 - 1
Dockerfile

@@ -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 \

+ 1 - 0
MANIFEST.in

@@ -1,3 +1,4 @@
 include README.rst
 include LICENSE
 graft lakesuperior/endpoints/templates
+graft lakesuperior/etc.defaults

+ 2 - 2
docker/etc/gunicorn.yml

@@ -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

+ 1 - 2
docs/conf.py

@@ -22,8 +22,7 @@ import sys
 
 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

+ 2 - 2
docs/setup.rst

@@ -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.
 

+ 16 - 2
lakesuperior/config_parser.py

@@ -5,6 +5,21 @@ from os import path, environ
 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):
     """
@@ -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 = {}

+ 0 - 0
etc.defaults/README → lakesuperior/etc.defaults/README


+ 0 - 0
etc.defaults/application.yml → lakesuperior/etc.defaults/application.yml


+ 0 - 0
etc.defaults/flask.yml → lakesuperior/etc.defaults/flask.yml


+ 0 - 0
etc.defaults/gunicorn.yml → lakesuperior/etc.defaults/gunicorn.yml


+ 0 - 0
etc.defaults/logging.yml → lakesuperior/etc.defaults/logging.yml


+ 0 - 0
etc.defaults/namespaces.yml → lakesuperior/etc.defaults/namespaces.yml


+ 0 - 0
etc.defaults/test.yml → lakesuperior/etc.defaults/test.yml


+ 2 - 4
lakesuperior/wsgi.py

@@ -6,12 +6,10 @@ from os import environ, makedirs, path
 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)

+ 0 - 1
setup.py

@@ -106,7 +106,6 @@ setup(
     #package_data={
     #},
     data_files=[
-        #('etc.defaults', glob('etc.defaults/*.yml')),
         ('data/bootstrap', glob('data/bootstrap/*')),
         ('data/ldpnr_store', ['data/ldpnr_store/.keep']),
         ('data/ldprs_store', ['data/ldprs_store/.keep']),