Skip to content

Commit

Permalink
refs #126. Makes data dir configurable and sets default to /sfm-data.…
Browse files Browse the repository at this point in the history
… Adds documentation.
  • Loading branch information
Justin Littman committed Jan 14, 2016
1 parent 820d1c1 commit 073f117
Show file tree
Hide file tree
Showing 5 changed files with 21 additions and 5 deletions.
11 changes: 11 additions & 0 deletions docs/install.rst
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,17 @@ Configuration
If setting ``DEBUG`` to false, the ``ALLOWED_HOSTS`` environment variable must be provided with a
comma-separated list of hosts. See the `Django documentation <https://docs.djangoproject.com/en/1.8/ref/settings/#allowed-hosts>`_
for ``ALLOWED_HOSTS``.
* The `data volume strategy <https://docs.docker.com/engine/userguide/dockervolumes/#creating-and-mounting-a-data-volume-container>`_
is used to manage the volumes that store SFM's data. By default, normal Docker volumes are used; to use
a host volume instead, add the host directory to the ``volumes`` field. This will allow you to access the
data outside of Docker. For example::

sfmdata:
image: ubuntu:14.04
command: /bin/true
volumes:
- /myhost/data:/sfm-data


Installation
------------
Expand Down
5 changes: 4 additions & 1 deletion sfm/sfm/settings/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,8 @@
RABBITMQ_USER = env.get('SFM_RABBITMQ_USER')
RABBITMQ_PASSWORD = env.get('SFM_RABBITMQ_PASSWORD')

# crispy forms bootstrap version
# crispy forms bootstrap version
CRISPY_TEMPLATE_PACK = 'bootstrap3'

# Directory where SFM data (e.g., harvested WARCs) is stored.
SFM_DATA_DIR = env.get("SFM_DATA_DIR", "/sfm-data")
4 changes: 3 additions & 1 deletion sfm/sfm/settings/test_settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,4 +6,6 @@
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'testdb'
}
}
}

SFM_DATA_DIR="/test-data"
4 changes: 2 additions & 2 deletions sfm/ui/jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
from django.core.exceptions import ObjectDoesNotExist
import logging
import datetime
from django.conf import settings

log = logging.getLogger(__name__)

Expand All @@ -29,8 +30,7 @@ def seedset_harvest(seedset_id):
# Collection
collection = seedset.collection
message["collection"]["id"] = "collection:{}".format(collection.id)
# TODO: Different approach for path
message["collection"]["path"] = "/tmp/collection/{}".format(collection.id)
message["collection"]["path"] = "{}/collection/{}".format(settings.SFM_DATA_DIR, collection.id)

# Credential
credentials = seedset.credential
Expand Down
2 changes: 1 addition & 1 deletion sfm/ui/test_jobs.py
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ def test_seedset_harvest(self, mock_rabbit_worker_class):
self.assertEqual("send_message", name)
message = args[0]
self.assertEqual("collection:{}".format(self.collection.id), message["collection"]["id"])
self.assertEqual("/tmp/collection/{}".format(self.collection.id), message["collection"]["path"])
self.assertEqual("/test-data/collection/{}".format(self.collection.id), message["collection"]["path"])
self.assertDictEqual(self.harvest_options, message["options"])
self.assertDictEqual({"token": "test_token1"}, message["seeds"][0])
self.assertDictEqual({"uid": "test_uid2"}, message["seeds"][1])
Expand Down

0 comments on commit 073f117

Please sign in to comment.