The installation process involves several steps.
- sdi server (this repository)
- sdi clients
Here we'll go through the installation of the server.
The server is a Django project running on Python 3. It comes with a requirements.txt to help manage dependencies. The system is made to connect with a Postgis backend for layers storage, so you'll have to install one or have details to connect to such database server. On the other hand, the project itself does not make use of a spatial database for its own storage, so any of Django supported database backend will do.
The reference deployment target is Debian 9, and following commands assume a similar system.
Install system dependencies with
sudo apt install \
build-essential \
python3-dev \
libxml2-dev \
libxslt1-dev\
libz-dev\
python-virtualenv\
git-coreFor Python dependencies, it is advised to first create a virtual environment
virtualenv -p python3 venv && source venv/bin/activateFrom within this directory, install dependencies with Pip
pip install -r requirements.txtFor deployment at IBGE, we'll also need
pip install django_python3_ldapThe project is distributed with a very generic settings file that you want to adjust to your configuration. Here's an example based on actual deployment. We create a file prod_settings.py at the root of sdi's directory, and further manage commands are called with --settings prod_settings
# call base settings
from main.settings import *
# a secret key
SECRET_KEY = 'a-secret-key'
# actual allowed hosts
ALLOWED_HOSTS = ['10.0.0.1']
# in case you want more applications loaded
INSTALLED_APPS.append('django_python3_ldap')
# an actual database setting
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'HOST': '127.0.0.1',
'PORT': 5432,
'NAME': 'name',
'PASSWORD': 'password',
'USER': 'user',
},
}
# here's a little loop to point to your postgis schemas
LAYERS_SCHEMAS = [
'shema_name_0',
'shema_name_1',
'shema_name_2',
'shema_name_3',
'shema_name_4',
]
for schema in LAYERS_SCHEMAS:
db_config = LAYERS_DB.copy()
db_config.update({
'OPTIONS': {
'options': '-c search_path={},public'.format(schema),
},
})
DATABASES[schema] = db_config
# clients are declared here in the form
# name : path/to/distribution
CLIENTS = {
'compose': '/var/sdi-webgis-rw/dist',
'view': '/var/sdi-webgis-ro/dist',
}
# it's unfortunate to have it here but we need to setup
# a default base layer somewhere that can be shared across applications
DEFAULT_BASE_LAYER = {
'name': {
'fr': 'urbisFRGray',
'nl': 'urbisNLGray',
},
'srs': 'EPSG:31370',
'params': {
'LAYERS': {
'fr': 'urbisFRGray',
'nl': 'urbisNLGray',
},
'VERSION': '1.1.1',
},
'url': {
'fr': 'https://geoservices-urbis.irisnet.be/geoserver/ows',
'nl': 'https://geoservices-urbis.irisnet.be/geoserver/ows',
},
}
# a django setting
MEDIA_ROOT = '/var/www/sdi/'Here we'll use ELK (elasticsearch, logstash & kibana). A simple setup is to run a ELK container such as http://elk-docker.readthedocs.io/ and python-logstash package.
LOGGING = {
'handlers': {
'logstash': {
'level': 'ERROR',
'class': 'logstash.TCPLogstashHandler',
'host': 'localhost',
'port': 5959, # Default value: 5959
'version': 1, # Version of logstash event schema. Default value: 0 (for backward compatibility of the library)
'message_type': 'django', # 'type' field in logstash message. Default value: 'logstash'.
'fqdn': False, # Fully qualified domain name. Default value: false.
'tags': ['django.request'], # list of tags. Default: None.
},
},
'loggers': {
'django.request': {
'handlers': ['logstash'],
'level': 'ERROR',
'propagate': True,
},
}