Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The JEDI web applications, https://experiments.jcsda.org and https://skylab.jcsda.org, run on two individual AWS EC2 instances in the jscda-noaa account in us-east-1. They are voila applications running on port 8866 on an nginx web server on ports 80/443. The web apps are simply python notebooks in the diag-plots repository with r2d2-client as the only JCSDA dependency. These packages are located in /home/ubuntu. A python virtual environment , e.i. "venv", located in /home/ubuntu/venv_web_app is used to install the required python packages and execute the voila application as a service.

...

Code in the header for the files diag-plots/src/jedi_data_viewer/jedi_data_viewer_experiments.py and diag-plots/src/jedi_data_viewer/jedi_data_viewer_skylab.py allow the programmatic assignment of R2D2's required environmental variables which configure the client. 

Code Block
languagepython
# Hack to set env for contacting server before importing r2d2 below
# I need to figure out how to set env vars in voila
os.environ['R2D2_USER'] = 'r2d2-web-app'
os.environ['R2D2_HOST'] = 'aws-us-east-1'
os.environ['R2D2_COMPILER'] = 'unknown'
os.environ['R2D2_API_KEY'] = '6a8bacf2-d6ae-11f0-9286-06d3b1fbe489'
os.environ['R2D2_LOG_LEVEL'] = 'SILENT'

...

For activating the web app's virtual environment in /home/ubuntu/venv_web_app and exporting R2D2's environmental variables for the client's configuration, execute source the file /home/ubuntu/setup.sh. 

Code Block
title/home/ubuntu/setup.sh
#!/bin/bash
  
source /home/ubuntu/venv_web_app/bin/activate

export R2D2_USER=r2d2-web-app
export R2D2_HOST=aws-us-east-1
export R2D2_COMPILER=unknown
export R2D2_API_KEY=6a8bacf2-d6ae-11f0-9286-06d3b1fbe489
export R2D2_LOG_LEVEL=SILENT

...

The Nginx configuration files are located at /etc/nginx/sites-enabled/experiments.jcsda.org and /etc/nginx/sites-enabled/skylab.jcsda.org.

Code Block
title/etc/nginx/sites-enabled/experiments.jcsda.org
server {
    server_name experiments.jcsda.org;
    proxy_buffering off;
    location / {
            proxy_pass http://localhost:8866;
            proxy_set_header Host $host;
            proxy_set_header X-Real-IP $remote_addr;
            proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;

            proxy_http_version 1.1;
            proxy_set_header Upgrade $http_upgrade;
            proxy_set_header Connection "upgrade";
            proxy_read_timeout 86400;
    }
    client_max_body_size 100M;
    error_log /var/log/nginx/error.log;

    listen 443 ssl; # managed by Certbot
    ssl_certificate /etc/letsencrypt/live/experiments.jcsda.org/fullchain.pem; # managed by Certbot
    ssl_certificate_key /etc/letsencrypt/live/experiments.jcsda.org/privkey.pem; # managed by Certbot
    include /etc/letsencrypt/options-ssl-nginx.conf; # managed by Certbot
    ssl_dhparam /etc/letsencrypt/ssl-dhparams.pem; # managed by Certbot
}

server {
    if ($host = experiments.jcsda.org) {
        return 301 https://$host$request_uri;
    } # managed by Certbot

    listen 80;
    server_name experiments.jcsda.org;
    return 301 https://$host$request_uri;
    # return 404; # managed by Certbot
}

...

The Voila configuration files are located at /usr/lib/systemd/system/voila.service. 

Code Block
title/usr/lib/systemd/system/voila.service
[Unit]
Description=Voila

[Service]
Type=simple
PIDFile=/run/voila.pid
ExecStart=/home/ubuntu/venv_web_app/bin/python3.10 -m voila --no-browser --show_traceback=False diag-plots/src/jedi_data_viewer/skylab_data_viewer.ipynb
User=ubuntu
WorkingDirectory=/home/ubuntu/
Restart=always
RestartSec=10

[Install]
WantedBy=multi-user.target

...