-
Notifications
You must be signed in to change notification settings - Fork 0
install
- git
- python-dev
- python-pip
- python-virtualenv
- postgresql-9.3
- postgresql-9.3-postgis-2.1
- postgresql-server-dev-9.3
- libjpeg-dev
sudo apt install git python3 python3-dev python3-virtualenv python3-pip postgresql postgresql-contrib postgis postgresql-server-dev-10 libjpeg-dev gdal-bin python-gdal python3-gdal libgdal-dev -y
sudo mkdir /usr/local/apps
sudo chown ubuntu /usr/local/apps
cd /usr/local/apps/
git clone https://github.com/Ecotrust/COMPASS.git
Replace USERNAME with an appropriate username for your database user below.
You will be prompted to enter a password for the new user as well. Keep track of these for the following steps as well.
sudo -u postgres createuser -s -P USERNAME
sudo -u postgres createdb -O USERNAME compass
sudo -u postgres psql -c "CREATE EXTENSION postgis; CREATE EXTENSION postgis_topology;" compass
Add db user to pg_hba.conf:
vim /etc/postgresql/10/main/pg_hba.conf
- add line to bottom:
local compass USERNAME 127.0.0.1/32 trust
- save and close
- restart postgres:
sudo service postgresql restart
python3 -m pip install --user virtualenv
cd /usr/local/apps/COMPASS/
python3 -m virtualenv env
source /usr/local/apps/COMPASS/env/bin/activate
pip install -r /usr/local/apps/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/COMPASS/mp/settings_local.template /usr/local/apps/COMPASS/mp/settings_local.py
Edit /usr/local/apps/COMPASS/mp/settings_local.py:
- SECRET_KEY = [something new]
- DATABASES
- 'NAME': 'compass'
- 'USER': '[compassdbuser]'
- 'PASSWORD': '[add password]',
- 'HOST': 'localhost',
- 'PORT': 5432,
- MEDIA_ROOT = '/usr/local/apps/COMPASS/mediaroot/'
- MEDIA_URL = '/media/'
- SOCKET_URL = ''
- SOCIAL_AUTH_GOOGLE_PLUS_KEY = ''
- SOCIAL_AUTH_GOOGLE_PLUS_SECRET = ''
- ADMIN_MEDIA_PATH = '/usr/local/apps/COMPASS/env/python3/site-packages/django/contrib/admin/static/admin/'
sudo chown -R {username} /usr/local/apps/COMPASS/mp/logs/
sudo vim ~/.bashrc
add this to the bottom:
alias dj="/usr/local/apps/COMPASS/env/bin/python3 /usr/local/apps/COMPASS/mp/manage.py"
alias djrun="dj runserver 0:8000 --noreload"
exit out of the ssh session and ssh back in again
dj syncdb
dj migrate
dj install_media
dj enable_sharing all
dj loaddata /usr/local/apps/COMPASS/mp/fixtures/layer-data.json
dj loaddata /usr/local/apps/COMPASS/mp/fixtures/project-settings.json
use djrun
to test that things are working as expected
If you are loading data from an existing database (created with something like pg_dump compass > ./compass_dump_20190529.sql
) and are starting from scratch on a new install, do the following:
- Identify the users/owners of the database that was dumped
- Update both your django settings and PostgreSQL settings (pg_hba) to include those users/owners
- restart PostgreSQL
- Change to postgres user:
sudo su postgres
- Drop your old DB:
dropdb compass
- Create an empty DB:
createdb compass
- Read in the file:
psql compass < ./compass_dump_20190529.sql
- Exit back to your primary user:
exit
- Drop your old DB:
- Run migrations, but you need to fake the initial DB creation:
dj migrate --fake-initial
For reference go here
TODO: Update with newer emperor approach Figure out why uwsgi isn't firing on boot
From inside your virualenv:
sudo apt-get install libpcre3 libpcre3-dev
apt-get install uwsgi uwsgi-plugin-python
pip install uwsgi
- test uwsgi install with
uwsgi --http :8000 --wsgi-file /usr/local/apps/COMPASS/mp/wsgi.py
sudo apt-get install nginx
sudo cp /usr/local/apps/COMPASS/deploy/compass.conf /etc/nginx/sites-available/compass
sudo rm /etc/nginx/sites-enabled/default
sudo ln -s /etc/nginx/sites-available/compass /etc/nginx/sites-enabled/compass
sudo service nginx (re)start
- copy relevant content from deploy/rc.local.template to /etc/rc.local to run uwsgi ini (deploy/compass_uwsgi.ini) on boot
-
sudo chmod 666 /usr/local/apps/COMPASS/mp/logs/main.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:
- 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
- In the admin, create a user with username 'public'
- chown www-data the following directories:
- media/extracted/
- media/planning_unit_sql/
- mediaroot/csvs/
- Use the admin hex-import script to import new base data
- Be sure that you have the correct species lookups (manage.py import_report_lookups)
- Set a cron job to clean out the mediaroot/csvs/ directory
- Set settings_local.py with
PUBLIC_CSV_DIR = '/home/vagrant/marine-planner/mediaroot/csvs/'
or similar - Be sure to install the public-drawing branch of Madrona in your environment
- py3 branch contains public-drawing by default
TODO: write notes on importing fonts
-
git
-
vagrant
-
Check out the code
-
Create and update mp/settings_local.py
- MEDIA_ROOT = '/home/vagrant/marine-planner/media'
- MEDIA_URL = '/media/'
- SOCKET_URL = ''
- SOCIAL_AUTH_GOOGLE_PLUS_KEY = ''
- SOCIAL_AUTH_GOOGLE_PLUS_SECRET = ''
- ADMIN_MEDIA_PATH = '/home/vagrant/.virtualenvs/marine-planner/lib/python2.7/site-packages/django/contrib/admin/static/admin/'
-
vagrant up
- (ignore) Exceptions: Exception: Your MEDIA_ROOT setting has to be a directory other than your madrona or project media folder!
- Likely this will choke on not being able to find ElementTree
- Copy ElementTree libraries from a live source
- run
vagrant provision
-
vagrant ssh
-
dj syncdb
- create superuser now
dj migrate
-
[ dj is alias fordj loaddata data_manager/fixtures/ofr_data_manager.json
python manage.py
] dj loaddata mp-settings/fixtures/ofr_mp_settings.json
dj loaddata ../mp/fixtures/project_settings.json
dj loaddata ../mp/fixtures/layer_data_proxy.json
-
-
dj site localhost:8000
-
dj createsuperuser
-
djrun
[ same aspython manage.py runserver 0.0.0.0:8000
] -
Point a browser at http://localhost:8000