-
Notifications
You must be signed in to change notification settings - Fork 0
Installing Dev Compass
This guide walks you through installing a dev instance of Compass alongside a previously installed production instance.
Having a Dev instance allows an admin to try out adding layers and themes without exposing them to the public site - being sure layer, metadata, and legend are all in place and displaying as expected prior to the reveal.
It is expected that you have an Ubuntu 18.04 LTS server with a running instance of Compass already installed. If you have not done this, please follow this guide first: Install Compass
Since you already have COMPASS sitting at /usr/local/apps/ and all of the helper scripts assume 'dev-compass', we can't just clone 'COMPASS' into apps without having a naming conflict. To avoid this, we'll clone into a temp directory, then rename and move the repo's root folder back into apps:
mkdir /usr/local/apps/devcd /usr/local/apps/dev/git clone https://github.com/Ecotrust/COMPASS.gitmv /usr/local/apps/dev/COMPASS/ /usr/local/apps/dev-compasscd /usr/local/apps/rm -r /usr/local/apps/dev/
The following steps will refer to USERNAME as a shorthand for the compass database user you created in the production Compass install. This does not have to be the same user, but if not, you will need to refer to those instructions to create a new DB user.
- create a new DB named 'compass_dev' (by default the production database is named 'compass')
sudo -u postgres createdb -O USERNAME compass_dev
- IF you are creating a database from scratch:
*
sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" compass_dev* From scratch you will need to perform some additional tasks after migration, including creating the 'public' user. See the 'Public Drawing' section of the production installation instructions for more info.- else, if you have another DB (perhaps your prod DB) you want to load in:
- DUMP the template DB (we'll use the local 'compass' db in this case)
sudo -u postgres pg_dump compass > /tmp/compass_dump.sql-
sudo -u postgres psql compass_dev < /tmp/compass_dump.sqlAdd db user to pg_hba.conf:
- else, if you have another DB (perhaps your prod DB) you want to load in:
vim /etc/postgresql/10/main/pg_hba.conf- add line to bottom:
local compass_dev USERNAME trust - save and close
- restart postgres:
sudo service postgresql restart
cd /usr/local/apps/dev-compass/
python3 -m virtualenv env
source /usr/local/apps/dev-compass/env/bin/activate
pip install -r /usr/local/apps/dev-compass/requirements.txt
Currently PyGDAL is a bit of a pain to install...
pip uninstall numpy
gdal-config --version
- Capture the output of that last command (such as
2.2.3) - Increment the last digit by 1 and plug it in to
pip install "pygdal<X.Y.Z"(such aspip install "pygdal<2.2.4")
cp /usr/local/apps/dev-compass/mp/settings_local.template /usr/local/apps/dev-compass/mp/settings_local.py
For USERNAME use the same database username used in step 3
Edit /usr/local/apps/dev-compass/mp/settings_local.py:
- SECRET_KEY = [something new]
- DATABASES
- 'NAME': 'compass_dev'
- 'USER': '[USERNAME]'
- 'PASSWORD': '[add password]',
- 'HOST': 'localhost',
- 'PORT': 5432,
- MEDIA_ROOT = '/usr/local/apps/dev-compass/mediaroot/'
- MEDIA_URL = '/media/'
- SOCKET_URL = ''
- SOCIAL_AUTH_GOOGLE_PLUS_KEY = ''
- SOCIAL_AUTH_GOOGLE_PLUS_SECRET = ''
- ADMIN_MEDIA_PATH = '/usr/local/apps/dev-compass/env/python3/site-packages/django/contrib/admin/static/admin/' If enabling public drawing, please also add:
- PUBLIC_CSV_DIR = '/usr/local/apps/dev-compass/mediaroot/csvs/'
Here, USERNAME refers to your OS user (i.e. 'ubuntu')
sudo chown -R USERNAME /usr/local/apps/dev-compass/mp/logs/
sudo vim ~/.bashrc
add this to the bottom:
alias djdev="/usr/local/apps/dev-compass/env/bin/python3 /usr/local/apps/dev-compass/mp/manage.py"
alias djdevrun="djdev runserver 0:8000 --noreload"
exit out of the ssh session and ssh back in again
mkdir /usr/local/apps/dev-compass/mediaroot/data_manager_uploads
sudo chgrp www-data /usr/local/apps/dev-compass/mediaroot/data_manager_uploads
If you created a new database:
djdev migrate
djdev loaddata /usr/local/apps/dev-compass/mp/fixtures/layer-data.json
djdev loaddata /usr/local/apps/dev-compass/mp/fixtures/project-settings.json
If you used psql to load in a DB from a dump file:
djdev migrate --fake-initial
In both cases, run the following:
djdev collectstatic
djdev enable_sharing all
use djdevrun to test that things are working as expected
From inside your virualenv:
pip install uwsgi- test uwsgi install with
uwsgi --http :8000 --wsgi-file /usr/local/apps/COMPASS/mp/wsgi.py -
sudo cp /usr/local/apps/dev-compass/deploy/compass.conf /etc/nginx/sites-available/compass_dev-
sudo vim /etc/nginx/sites-available/compass_dev- remove the 'arcgix_services' section
- The duplication breaks NGINX - does removing it break any assumptions?
- update
server_nameto use your specific compass-dev url - update the logfile locations to use '_dev' in the names
- udpate /static and /media to point at 'dev-compass' instead of 'COMPASS'
- under '/' update 'uwsgi_pass unix:///tmp/compass-*dev-*socket;'
- remove the 'arcgix_services' section
-
sudo ln -s /etc/nginx/sites-available/compass_dev /etc/nginx/sites-enabled/compass_dev- test the configuration with
sudo nginx -t sudo cp /usr/local/apps/dev-compass/deploy/compass_dev.service /etc/systemd/system/compass_dev.servicesudo systemctl enable compass_dev.servicesudo cp /usr/local/apps/dev-compass/deploy/compass_dev.ini /etc/uwsgi/apps-enabled/compass_dev.inisudo service nginx restartsudo service compass_dev startsudo service compass_dev restart-
sudo chmod 666 /usr/local/apps/dev-compass/mp/logs/main.log<- TODO: make this not necessary -
sudo chmod 666 /usr/local/apps/dev-compass/mp/logs/main_debug.log<- TODO: make this not necessary sudo reboot- In a few minutes, test your URL in a browser to see that everything came up as expected
If you are intending to allow public drawing on your install, you will want to follow these additional steps:
-
If you created a new database from scratch (not imported from a dump) be sure to:
- Create a django user with username 'public'
- Use the admin hex-import script to import new base data
- Check that you have the correct species lookups (manage.py import_report_lookups)
-
chown www-data the following directories:
- media/extracted/
- media/planning_unit_sql/
- mediaroot/csvs/
-
Be sure to install the public-drawing branch of Madrona in your environment
- py3 branch contains public-drawing by default
- get fetch/merge
- the scenarios/migrations/0003_auto__del... file does not seem to play well. Grab the version on the ODFW production server
- manage.py syncdb, migrate, and install_media
cp -r /usr/local/apps/COMPASS/media/compass/fonts/ /usr/local/apps/dev-compass/media/compass/
cp /usr/local/apps/COMPASS/media/compass/css/compass_fonts.css /usr/local/apps/dev-compass/media/compass/css/
djdev collectstatic