... | ... | @@ -20,6 +20,10 @@ server { |
|
|
include uwsgi_params;
|
|
|
uwsgi_pass localhost:8021;
|
|
|
}
|
|
|
location /v21 {
|
|
|
include uwsgi_params;
|
|
|
uwsgi_pass localhost:8022;
|
|
|
}
|
|
|
|
|
|
listen 443 ssl; # managed by Certbot
|
|
|
ssl_certificate /etc/letsencrypt/live/api.db.nomics.world/fullchain.pem; # managed by Certbot
|
... | ... | @@ -60,28 +64,51 @@ threads = 2 |
|
|
stats = :8001
|
|
|
```
|
|
|
|
|
|
As `cepremap`, create file `/home/cepremap/production-config/dbnomics-api-uwsgi-v22.ini`:
|
|
|
|
|
|
```ini
|
|
|
[uwsgi]
|
|
|
socket = localhost:8022
|
|
|
|
|
|
plugin = python3
|
|
|
|
|
|
; mount apps
|
|
|
mount = /v22=dbnomics_api.app:app
|
|
|
|
|
|
; rewrite SCRIPT_NAME and PATH_INFO accordingly
|
|
|
manage-script-name = true
|
|
|
|
|
|
virtualenv = /home/cepremap/virtualenvs/dbnomics-api-v22
|
|
|
|
|
|
processes = 4
|
|
|
enable-threads = true
|
|
|
threads = 2
|
|
|
|
|
|
; Enable then use "uwsgitop :8002" to see processes.
|
|
|
stats = :8002
|
|
|
```
|
|
|
|
|
|
As `root`:
|
|
|
|
|
|
```bash
|
|
|
ln -s /home/cepremap/production-config/dbnomics-api-uwsgi-v21.ini /etc/uwsgi/apps-available/
|
|
|
ln -s /home/cepremap/production-config/dbnomics-api-uwsgi-v22.ini /etc/uwsgi/apps-available/
|
|
|
cd /etc/uwsgi/apps-enabled
|
|
|
ln -s ../apps-available/dbnomics-api-uwsgi-v21.ini .
|
|
|
ln -s ../apps-available/dbnomics-api-uwsgi-v22.ini .
|
|
|
systemctl restart uwsgi.service
|
|
|
```
|
|
|
|
|
|
The logs of uwsgi applications are in `/var/log/uwsgi/app/`. To check that the service is well started, the last lines of `/var/log/uwsgi/app/dbnomics-api-uwsgi-v21.log` should display something like "spawned uWSGI worker 1 (and the only) (pid: 8936, cores: 1)" and not contain any error (grep for "Traceback" keyword).
|
|
|
|
|
|
To test: open https://api.db.nomics.world/v21/
|
|
|
|
|
|
It should display:
|
|
|
To test, open https://api.db.nomics.world/v22/ or any previous version deployed. It should display:
|
|
|
|
|
|
```json
|
|
|
{
|
|
|
"_meta": {
|
|
|
"python_project_version": "0.19.0",
|
|
|
"python_project_name": "DBnomics-API"
|
|
|
"version": "22.0.0"
|
|
|
},
|
|
|
"apidocs_href": "/apidocs",
|
|
|
"message": "This is the home page of DBnomics Web API. Its documentation is here: https://api.db.nomics.world/v21/apidocs"
|
|
|
"apidocs_href": "/v22/apidocs",
|
|
|
"message": "This is the home page of DBnomics Web API. Its documentation is here: https://api.db.nomics.world/v22/apidocs"
|
|
|
}
|
|
|
``` |