Skip to content
Alexandre Flament edited this page May 19, 2022 · 12 revisions

Installation

What the installation is going to do

  • Add a new user ebiodiv (the choice of the name is actually free, this document is going to use ebiodiv)
  • Install files in the /opt/ebiodiv directory (the choice of the directory is actually free, this document is going to use /opt/ebiodiv )
  • Add the /etc/systemd/system/ebiodiv-backend.service file (the name of the systemd unit is free too)
  • Change the Apache httpd configuration
  • Add Debian packages
  • Open a TCP port on localhost (8888 is this document, feel free to change it)

Required Debian package

apt-get install git build-essential python3 python3-dev

Create a dedicate user for the backend service

adduser --system --group --disabled-password --disabled-login --home /opt/ebiodiv --shell /bin/sh ebiodiv

Frontend

su - ebiodiv
git clone --branch dist https://github.com/bitem-heg-geneve/ebiodiv-matching-frontend

Backend

git clone and install dependencies:

su - ebiodiv
git clone https://github.com/bitem-heg-geneve/ebiodiv-matching-backend
cd ebiodiv-matching-backend
python3 -m venv venv
source ./venv/bin/activate
pip install --upgrade pip setuptools wheel
pip install -e .

create /opt/ebiodiv/ebiodiv-matching-backend/config.ini with the ebiodiv owner:

[server]
root_path=/
host=localhost
port=8888 # change this according to your need
default_proc_name=ebiodiv  # name of the Unix threads
# worker=8
# ssl_keyfile=
# ssl_certfile=

[datasource]
url=https://tb.plazi.org/GgServer/gbifOccLinkData/
timeout=180

Start the backend using a systemd unit

Create /etc/systemd/system/ebiodiv-backend.service with the root owner:

[Unit]
Description=ebiodiv backend service
After=network-online.target

[Service]
Type=simple
Restart=on-failure

User=ebiodiv
Group=ebiodiv

WorkingDirectory=/opt/ebiodiv/ebiodiv-matching-backend/
ExecStart=/opt/ebiodiv/ebiodiv-matching-backend/venv/bin/ebiodiv-matching-backend --production
TimeoutStopSec=3

[Install]
WantedBy=multi-user.target

Start the service:

systemctl start ebiodiv-backend.service

Alternative to previous step: start the backend using gunicorn from the distro

the backend is a ASGI application, so it can be started gunicorn from Debian.

Second alternative to previous step: start the backenbd using Docker

there is a Dockerfile to build a docker image.

Apache configuration

In the following configuration replace the /ebiodiv path by another path if needed:

ProxyPass /ebiodiv/api/v2 http://localhost:8888 connectiontimeout=180 timeout=900 
ProxyPassReverse /ebiodiv/api/v2 http://localhost:8888

Alias /ebiodiv "/opt/ebiodiv/ebiodiv-matching-frontend/"
<Directory "/opt/ebiodiv/ebiodiv-matching-frontend/">
  Options +Indexes
  AllowOverride None
  Order allow,deny
  Allow from all
</Directory>

update procedure

systemctl stop ebiodiv-backend
su - ebiodiv
cd ebiodiv-matching-frontend
git pull
cd ../ebiodiv-matching-backend
git pull
source ./venv/bin/activate
pip install -e .
exit
systemctl start ebiodiv-backend