Browse Source

Zero-config startup; default locations in data directory.

Stefano Cossu 6 years ago
parent
commit
f56960605f
8 changed files with 46 additions and 16 deletions
  1. 4 0
      .gitignore
  2. 28 6
      README.md
  3. 0 0
      data/log/.keep
  4. 0 0
      data/run/.keep
  5. 2 2
      etc.defaults/application.yml
  6. 1 1
      etc.defaults/gunicorn.py
  7. 3 1
      fcrepo
  8. 8 6
      lakesuperior/config_parser.py

+ 4 - 0
.gitignore

@@ -102,3 +102,7 @@ venv.bak/
 
 # mypy
 .mypy_cache/
+
+# Default LAKEsuperior data directories
+data/ldpnr_store
+data/ldprs_store

+ 28 - 6
README.md

@@ -60,6 +60,10 @@ interested in evaluating this project.
 
 ## Installation
 
+**Note:** These instructions have been tested on Linux. They may work on Darwin
+with little or no modification, and possibly on Windws with some modifications.
+Feedback is welcome.
+
 ### Dependencies
 
 1. Python 3.5 or greater.
@@ -75,18 +79,36 @@ dependencies and should be automatically installed.
 1. Clone this repo
 1. `cd` into repo folder
 1. Install dependencies: `pip install -r requirements.txt`
-1. Copy the `etc.skeleton` folder to a separate location
-1. 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)
-1. Configure the application if needed. The default settings should be fine
-   for evaluation.
 1. 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.
 1. Run `./lsup_admin bootstrap` to initialize the binary and graph stores
 1. Run `./fcrepo`.
 
+### Configuration
+
+The app should run for testing and evaluation purposes without any further
+configuration. All the application data are stored by default in the `data`
+directory.
+
+To change the default configuration you should:
+
+1. Copy the `etc.skeleton` folder to a separate location
+1. 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)
+1. Configure the application
+1. Bootstrap the app or copy the original data folders to the new location if
+   any loction options changed
+1. (Re)start the server: `./fcrepo`
+
+The configuration options are documented in the files.
+
+**Note:** `test.yml` must specify a different location for the graph and for
+the binary stores than the default one, otherwise running a test suite will
+destroy your main data store. The application will issue an error message and
+refuse to start if these locations overlap.
+
 ### Production deployment
 
 If you like fried repositories for lunch, deploy before 11AM.

+ 0 - 0
data/log/.keep


+ 0 - 0
data/run/.keep


+ 2 - 2
etc.defaults/application.yml

@@ -19,7 +19,7 @@ store:
     # MUST support SPARQL 1.1 query and update.
     ldp_rs:
         # Directory where the RDF data files are stored.
-        location: /tmp/fcrepo/data/ldprs_store
+        location: data/ldprs_store
 
         # store layout. At the moment, only `rsrc_centric_layout`is supported.
         layout: rsrc_centric_layout
@@ -48,7 +48,7 @@ store:
         layout: default_layout
 
         # The filesystem path to the root of the binary store.
-        path: /tmp/fcrepo/data/ldpnr_store
+        path: data/ldpnr_store
 
         # How to split the balanced pairtree to generate a path. The hash
         # string is defined by the uuid.algo parameter value.

+ 1 - 1
etc.defaults/gunicorn.py

@@ -1,7 +1,7 @@
 # See: http://docs.gunicorn.org/en/stable/settings.html
 
 # Directory where to store logs, PIDfile, etc.
-_data_dir = '/tmp'
+_data_dir = 'data/'
 
 # Set app_mode to either 'prod', 'test' or 'dev'.
 # 'prod' is normal running mode. 'test' is used for running test suites.

+ 3 - 1
fcrepo

@@ -1,3 +1,5 @@
 #!/bin/bash
+default_conf_dir="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )/etc.defaults"
+conf_dir=${FCREPO_CONFIG_DIR:-$default_conf_dir}
 
-gunicorn -c "${FCREPO_CONFIG_DIR}/gunicorn.py" server:fcrepo
+gunicorn -c "${conf_dir}/gunicorn.py" server:fcrepo

+ 8 - 6
lakesuperior/config_parser.py

@@ -1,6 +1,7 @@
-import os
 import sys
 
+from os import path, environ
+
 import hiyapyco
 import yaml
 
@@ -15,10 +16,11 @@ configs = (
 config = {}
 
 # Parse configuration
-if 'FCREPO_CONFIG_DIR' in os.environ:
-    CONFIG_DIR = os.environ['FCREPO_CONFIG_DIR']
-else:
-    CONFIG_DIR = os.path.dirname(os.path.abspath(__file__)) + '/etc'
+CONFIG_DIR = environ.get(
+        'FCREPO_CONFIG_DIR',
+        path.dirname(path.dirname(path.abspath(__file__))) + '/etc.defaults')
+
+print('Reading configuration at {}'.format(CONFIG_DIR))
 
 for cname in configs:
     file = '{}/{}.yml'.format(CONFIG_DIR , cname)
@@ -31,7 +33,7 @@ error_msg = '''
 ** WARNING! **
 **************
 
-Your test {} store endpoint is set to be the same as the production endpoint.
+Your test {} store location is set to be the same as the production location.
 This means that if you run a test suite, your live data may be wiped clean!
 
 Please review your configuration before starting.