From b084668c01b7ec6a6c8a6e62c1006bca3fd94ba3 Mon Sep 17 00:00:00 2001 From: Disassembler Date: Thu, 30 Nov 2017 10:11:59 +0100 Subject: [PATCH] Split CKAN and Datapusher virtual envs --- ckan.sh | 19 ++++++++++++------- ckan/etc/ckan/datapusher.wsgi | 2 +- .../uwsgi/apps-available/ckan-datapusher.ini | 3 +-- 3 files changed, 14 insertions(+), 10 deletions(-) diff --git a/ckan.sh b/ckan.sh index 1e8956b..7b157d4 100755 --- a/ckan.sh +++ b/ckan.sh @@ -3,7 +3,7 @@ SOURCE_DIR=$(realpath $(dirname "${0}")) # Install dependencies for CKAN -apt-get -y --no-install-recommends install gcc libpq-dev python-dev python-virtualenv redis-server uuid-runtime virtualenv +apt-get -y --no-install-recommends install gcc libpq-dev python-dev python-virtualenv redis-server virtualenv # Install dependencies for Solr apt-get -y --no-install-recommends install openjdk-8-jre-headless lsof @@ -12,9 +12,13 @@ apt-get -y --no-install-recommends install openjdk-8-jre-headless lsof mkdir -p /srv/ckan virtualenv --no-site-packages --python=/usr/bin/python2.7 /srv/ckan /srv/ckan/bin/pip install -e 'git+https://github.com/ckan/ckan.git#egg=ckan' -/srv/ckan/bin/pip install -e 'git+https://github.com/ckan/datapusher.git#egg=datapusher' /srv/ckan/bin/pip install -r /srv/ckan/src/ckan/requirements.txt -/srv/ckan/bin/pip install -r /srv/ckan/src/datapusher/requirements.txt + +# Install Datapusher python virtual environment +mkdir -p /srv/ckan-datapusher +virtualenv --no-site-packages --python=/usr/bin/python2.7 /srv/ckan-datapusher +/srv/ckan-datapusher/bin/pip install -e 'git+https://github.com/ckan/datapusher.git#egg=datapusher' +/srv/ckan-datapusher/bin/pip install -r /srv/ckan-datapusher/src/datapusher/requirements.txt # Install CKAN extensions /srv/ckan/bin/pip install -e 'git+https://github.com/ckan/ckanext-basiccharts#egg=ckanext_basiccharts' @@ -31,7 +35,7 @@ virtualenv --no-site-packages --python=/usr/bin/python2.7 /srv/ckan /srv/ckan/bin/pip install -r /srv/ckan/src/ckanext-datasetthumbnail/requirements.txt /srv/ckan/bin/pip install -r /srv/ckan/src/ckanext-dgvat-xls/requirements.txt -# Donwload Solr +# Download Solr wget http://archive.apache.org/dist/lucene/solr/6.5.1/solr-6.5.1.tgz -O /tmp/solr-6.5.1.tgz tar xzf /tmp/solr-6.5.1.tgz -C /opt/ mv /opt/solr-6.5.1 /opt/solr @@ -49,6 +53,7 @@ adduser --system --group --home /srv/ckan --shell /bin/false ckan chown -R ckan:ckan /srv/ckan/ mkdir /var/lib/ckan chown ckan:ckan /var/lib/ckan +chown ckan:ckan /var/lib/ckan-datapusher # Create Solr OS user adduser --system --group --home /var/lib/solr --shell /bin/false solr @@ -70,7 +75,7 @@ systemctl restart solr # Configure CKAN export CKAN_SECRET=$(head -c 18 /dev/urandom | base64) -export CKAN_UUID=$(uuidgen -r) +export CKAN_UUID=$(python -c "import uuid; print uuid.uuid4()") mkdir /etc/ckan envsubst <${SOURCE_DIR}/ckan/etc/ckan/ckan.ini >/etc/ckan/ckan.ini cp ${SOURCE_DIR}/ckan/etc/ckan/datapusher.wsgi /etc/ckan/datapusher.wsgi @@ -86,8 +91,8 @@ sudo -u ckan /srv/ckan/bin/paster --plugin=ckan datastore set-permissions -c /et # Create admin account export CKAN_ADMIN_USER="admin" -export CKAN_ADMIN_UUID=$(uuidgen -r) -export CKAN_ADMIN_APIKEY=$(uuidgen -r) +export CKAN_ADMIN_UUID=$(python -c "import uuid; print uuid.uuid4()") +export CKAN_ADMIN_APIKEY=$(python -c "import uuid; print uuid.uuid4()") export CKAN_ADMIN_PWD=$(head -c 12 /dev/urandom | base64) export CKAN_ADMIN_HASH=$(/srv/ckan/bin/python ${SOURCE_DIR}/ckan/ckan-adminpwd.py ${CKAN_ADMIN_PWD}) export CKAN_ADMIN_EMAIL="admin@example.com" diff --git a/ckan/etc/ckan/datapusher.wsgi b/ckan/etc/ckan/datapusher.wsgi index 08e0f12..7728628 100644 --- a/ckan/etc/ckan/datapusher.wsgi +++ b/ckan/etc/ckan/datapusher.wsgi @@ -2,7 +2,7 @@ import os -activate_this = os.path.join('/srv/ckan/bin/activate_this.py') +activate_this = '/srv/ckan-datapusher/bin/activate_this.py' execfile(activate_this, dict(__file__=activate_this)) import ckanserviceprovider.web as web diff --git a/ckan/etc/uwsgi/apps-available/ckan-datapusher.ini b/ckan/etc/uwsgi/apps-available/ckan-datapusher.ini index 74ae530..5aa52f7 100644 --- a/ckan/etc/uwsgi/apps-available/ckan-datapusher.ini +++ b/ckan/etc/uwsgi/apps-available/ckan-datapusher.ini @@ -2,7 +2,6 @@ uid = ckan gid = ckan chown-socket = www-data:www-data -chdir = /srv/ckan -exec-asap = /srv/ckan/update-ip.sh +chdir = /srv/ckan-datapusher disable-logging = true file = /etc/ckan/datapusher.wsgi