Skip to content

Deploying DataGateway

Louise Davies edited this page Nov 19, 2019 · 12 revisions

Below I will describe how I set up datagateway-table and datagateway-api on the scigateway-preprod.esc.rl.ac.uk machine.

Server setup

1. Install node

(Instructions)

2. Install Apache

yum install httpd

3. Install Python3

yum install epel-release
yum install python36 python36-pip

4. Install mod_wsgi

yum install httpd-devel
pip3 install mod-wsgi
mod_wsgi-express install-module > /etc/httpd/conf.modules.d/02-wsgi.conf

5. Open firewall ports

iptables -A INPUT -p tcp -m tcp --dport 5000 -j ACCEPT
iptables -A INPUT -p tcp -m tcp --dport 5001 -j ACCEPT
iptables-save > /etc/sysconfig/iptables

6. Start Apache

systemctl start httpd

Deploying datagateway-table

On scigateway-preprod.esc.rl.ac.uk, the code for datagateway and datagateway-api is cloned and built by the ICAT glassfish user.

1. Build datagateway-table

git clone https://github.com/ral-facilities/datagateway.git
cd datagateway
npm install
cd packages/datagateway-table
npm run build

This will build datagateway-table in production mode. This will minimise the JavaScript and perform other performance improvements, as well as building it in such a way that the parent app can load it.

2. Copy build contents to web folder

cp build/* /var/www/datagateway-table/

3. Set up apache virtualhost

/etc/httpd/conf.d/datagateway-table.conf

Listen 5001
<VirtualHost *:5001>
    DocumentRoot "/var/www/datagateway-table"
    ServerName http://scigateway-preprod.esc.rl.ac.uk

    <Directory /var/www/datagateway-table>
        RewriteEngine off

        Options Indexes FollowSymLinks
        AllowOverride None
        Require all granted
    </Directory>
</VirtualHost>
systemctl restart httpd

This sets up Apache on port 5001, and tells it to serve the contents of /var/www/datagateway-table

4. Copy contents of settings.json to /var/www/html/settings.json

Currently, datagateway-table expects the settings file to be in the web root, but SciGateway settings file is stored there. For now, copying in the contents of datagateway-table's settings file into SciGateway's is sufficient to get it working. Ensure that api url points to scigateway-preprod.esc.rl.ac.uk:5000

Deploying datagateway-api

In order for datagateway-table to be able to load data, it needs to be able to contact the api server.

1. Clone datagateway-api

git clone https://github.com/ral-facilities/datagateway-api.git

2. Add VirtualHost config to Apache:

/etc/httpd/conf.d/datagateway-api.conf

Listen 5000
<VirtualHost *:5000>
     ServerName http://scigateway-preprod.esc.rl.ac.uk

     WSGIPassAuthorization On
     WSGIDaemonProcess datagateway-api user=glassfish group=glassfish threads=1 python-path=/home/glassfish/scigateway/datagateway-api
     WSGIScriptAlias /datagateway-api /var/www/datagateway-api/datagateway-api.wsgi process-group=datagateway-api application-group=%{GLOBAL}

     <Directory /var/www/datagateway-api>
          Options FollowSymLinks
          AllowOverride None
          Require all granted
     </Directory>
</VirtualHost>

This sets up Apache to run mod_wsgi on port 5000. It expects a wsgi file in /var/www/datagateway-api/datagateway-api.wsgi and runs the server as the unprivileged glassfish user.

3. Set up wsgi file

/var/www/datagateway-api/datagateway-api.wsgi

#! /usr/bin/python3.6

import logging
import sys
logging.basicConfig(stream=sys.stderr)
sys.path.insert(0, '/home/glassfish/scigateway/datagateway-api/src/')

from main import app as application
systemctl restart httpd

This tells mod_wsgi the actual location of our app and how to run it.

Clone this wiki locally