gomss-site Web App Deployment

The gomss-site web app is deployed on an Ubuntu 16.04 virtual machine that is access via the anchor.phys.ocean.dal.ca server. A reverse proxy in the ocean.dal.ca infrastructure mounts that web app at https://gomss.ocean.dal.ca/. The infrastructure was set up by Daniel Morrison of the Dalhousie Oceanography Department IT staff in the spring/summer of 2018.

Shell Access

Shell access is via proxy through anchor.phys.ocean.dal.ca with the appropriate ssh configuration settings:

Host anchor
    Hostname anchor.phys.ocean.dal.ca
    User dlatornell
    IdentityFile ~/.ssh/gomss-web_id_rsa
Host gomss-nowcast-web
    Hostname gomss-nowcast.ocean.lan
    User dlatornell
    IdentityFile ~/.ssh/gomss-web_id_rsa
    ProxyCommand ssh -q -W %h:%p anchor

nowcast-sys File System

The /data1/dlatornell/nowcast-sys/ file system from the nemo compute cluster is mounted via sshfs and autofs.

Operating System Packages

Add the mercurial-ppa repository to the OS package management collection, and install the Mercurial version control tool, and the mg editor:

$ sudo add-apt-repository -y ppa:mercurial-ppa/releases
$ sudo apt-get update
$ sudo apt-get install -y mercurial mg

Mercurial Repository for Web App

Clone the gomss-site repo into /home/datornell/ on gomss-nowcast-web:

$ cd /home/datornell/
$ hg clone ssh://hg@bitbucket.org/gomss-nowcast/gomss-site

Conda Environment Manager

Download and install miniconda3, and update conda to the most recent release:

$ cd /home/datornell/
$ wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh
$ bash Miniconda3-latest-Linux-x86_64.sh
$ ./miniconda3/bin/conda update -n base conda

bash Aliases

Create a /home/dlatornell/.bash_aliases file with the contents:

# .bashrc personalization

# Aliases
alias rm="rm -i"
# Force password auth for ssh
alias ssh-pw="ssh -o PreferredAuthentications=password -o PubkeyAuthentication=no"

# Enable conda
source /home/dlatornell/miniconda3/etc/profile.d/conda.sh

# Functions:
ttitle() {
    echo -ne "\033]0;"${1}"\007";
}

# Shorten prompt to tail of pwd
PS1="\W$ "

Exit the present shell session and start a new one so that the above take effect.

Conda Environment for Web App

Create a conda environment in which to install the app and its dependencies:

$ cd /home/datornell/gomss-site/
$ conda env create -f environment-prod.yaml
$ conda activate gomss-site-env
(gomss-site-env)$ pip install --editable .

Create a conda environment file to export the necessary environment variables when the environment is activated:

(gomss-site-env)$ mkdir -p /home/dlatornell/miniconda3/envs/gomss-site-env/etc/conda/activate.d/
(gomss-site-env)$ mg /home/dlatornell/miniconda3/envs/gomss-site-env/etc/conda/activate.d/activate-envvars.sh

and populate the file with:

export GOMSS_SITE_ENV=/home/dlatornell/miniconda3/envs/gomss-site-env/
export GOMSS_SITE=/home/dlatornell/gomss-site/
export NOWCAST_LOGS=/data1/dlatornell/nowcast-sys/logs/nowcast/
export SENTRY_DSN=

setting the value of SENTRY_DSN to URL generated by sentry for the project; (available from https://sentry.io/settings/43ravens/gomss-site/keys/).

Create a conda environment file to unset those environment variables when the environment is deactivated:

(gomss-site-env)$ mkdir -p /home/dlatornell/miniconda3/envs/gomss-site-env/etc/conda/deactivate.d/
(gomss-site-env)$ mg /home/dlatornell/miniconda3/envs/gomss-site-env/etc/conda/deactivate.d/deactivate-envvars.sh

and populate the file with:

unset GOMSS_SITE_ENV
unset GOMSS_SITE
unset NOWCAST_LOGS
unset SENTRY_DSN

Logs Directory

Create a directory to hold the log files from the web app, and the process manager that it runs under:

$ mkdir /home/datornell/gomss-site-logs/

The circus.log file that will appear in this directory is the log file containing messages from the circus process manager that controls starting, stopping, and restarting the app. It also ensures that the app is restarted automatically if it dies or is killed for some reason.

The pyramid.log file that will appear in this directory is the log file containing messages from the app itself.

Launch Web App on VM Startup

Add the following lines to /etc/rc.local to start the circusd process manager daemon when the VM starts up, and thence start the web app:

# Launch process manager for gomss-site web app
GOMSS_SITE_ENV=/home/dlatornell/miniconda3/envs/gomss-site-env/
GOMSS_SITE=/home/dlatornell/gomss-site/
NOWCAST_LOGS=/data1/dlatornell/nowcast-sys/logs/nowcast/
SENTRY_DSN=
PYTHON=${GOMSS_SITE_ENV}/bin/python
CIRCUSD=${GOMSS_SITE_ENV}/bin/circusd
su dlatornell -c " \
  GOMSS_SITE_ENV=${GOMSS_SITE_ENV}  \
  GOMSS_SITE=${GOMSS_SITE} \
  NOWCAST_LOGS=${NOWCAST_LOGS} \
  SENTRY_DSN=${SENTRY_DSN} \
  ${PYTHON} ${CIRCUSD} --daemon ${GOMSS_SITE}/circus-prod.ini \
"

setting the value of SENTRY_DSN to URL generated by sentry for the project; (available from https://sentry.io/settings/43ravens/gomss-site/keys/).