Andor wrapper for Evora and Flask server.
evora-server
requires the proprietary Andor libraries to be installed in /usr/local/lib
. The library can be used for debugging without the Andor libraries, but they are necessary to run the actual camera.
To install evora-server
, clone the repository and run
pip install .
or to install in editable mode
pip install -e .
To run the server, from a terminal at the root of the project, execute
python app.py
which is equivalent to
flask --debug run --port 3000
To run the server in debug mode, with the dummy module mocking the camera, edit debug.py
and set DEBUGGING = True
.
evora-server
will save camera files to /data/ecam/DATE
where DATE
is in the format 20230504
and rotates at midnight UTC.
If /data/ecam
does not exist, create it with mkdir -p
and make sure it has the right permissions for evora-server
to write to it.
The recommended way to deploy evora-server
is behind a gunicorn web server. To run the Flask webapp from gunicorn
, execute
gunicorn -w 1 'app:app'
which will spin a web server with one worker. Currently the app is limited to run with one single worker since the connection to the camera cannot be shared.
To run this command in the background as a systemd service, create a file /etc/systemd/system/evora-server.service
with the contents
[Unit]
Description=evora-server
[Service]
WorkingDirectory=/home/mrouser/Github/evora-server
ExecStart=/home/mrouser/Github/evora-server/gunicorn-start.sh
[Install]
WantedBy=multi-user.target
Here we are pointing to the file gunicorn-start.sh
in the repo, which loads the conda environment and starts gunicorn. This may need to be changed for a location other than MRO. Then start the systemd service with
sudo systemctl daemon-reload
sudo systemctl enable --now enable evora-server
sudo systemctl restart evora-server
In addition to gunicorn
, a reverse proxy is needed to run the Evora client and server in the same web server. In Ubuntu, install nginx
(alternatively you can use Apache
) with
sudo apt update
sudo apt install nginx
and adjust the firewall to open the desired ports. Then start nginx
with
sudo systemctl enable --now nginx
We'll now add a new site for Evora. Create a new file /etc/nginx/sites-enabled/evora.conf
with
sudo vim /etc/nginx/sites-enabled/evora.conf
and include the configuration
server {
listen 80;
listen [::]:80;
server_name localhost;
access_log /usr/local/var/log/nginx/evora.log;
location /api/ {
proxy_pass http://127.0.0.1:8000/;
proxy_set_header Host $host;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_connect_timeout 75s;
proxy_read_timeout 1800s;
}
location /data {
alias /data;
autoindex on;
index index.html index.php;
}
}
This configuration creates a server running on port 80
(the default HTTP) and adds a reverse proxy to where gunicorn
is running the Flask webapp. Note that we allow requests to the API to take as much as 30 minutes (which should be enough for most exposure times). It also creates a route to expose and browse /data
.
After this, restart nginx
with
sudo systemctl restart nginx
and test that it works by navigating to http://localhost/api/getTemperature.