ops: deploy webapp on Gaia

Add systemd service + start script and deploy all that on Gaia.
This commit is contained in:
Félix Baylac-Jacqué 2022-02-22 14:57:07 +01:00
parent 38c67ee588
commit 6308ae9cea
3 changed files with 37 additions and 1 deletions

View file

@ -0,0 +1,29 @@
[Unit]
After=network.target
[Install]
WantedBy=default.target
[Service]
Environment="PORT=6665"
# /etc/ftth-ipe-map/conf.ini
ConfigurationDirectory=ftth-ipe-map
WorkingDirectory=/srv/www/ftth-ipe-map/webapp/
ExecStart=/srv/www/ftth-ipe-map/webapp/startGunicornService
User=ftth-ipe-map
Group=ftth-ipe-map
Restart=on-failure
RestartSec=30
# Sandboxing
#ProtectSystem=strict
#ProtectHome=tmpfs
PrivateTmp=true
PrivateDevices=true
ProtectClock=true
ProtectKernelTunables=true
ProtectKernelModules=true
ProtectKernelLogs=true
ProtectControlGroups=true
RestrictAddressFamilies=AF_INET
RestrictRealtime=true

View file

@ -9,7 +9,7 @@ class Config(TypedDict):
dbPath: str dbPath: str
def parseConfig() -> Config: def parseConfig() -> Config:
cfg_path = os.environ.get("CONFIG", "/etc/ipe-ftth-elig/conf.ini") cfg_path = os.environ.get("CONFIG", "/etc/ftth-ipe-map/conf.ini")
cfg = configparser.ConfigParser() cfg = configparser.ConfigParser()
with open(cfg_path, "r") as f: with open(cfg_path, "r") as f:
cfg.read_file(f) cfg.read_file(f)

7
webapp/startGunicornService Executable file
View file

@ -0,0 +1,7 @@
#!/bin/bash
set -euo pipefail
export PATH="/usr/bin/:/bin/:/srv/www/Axione-FTTH-Test/.poetry/bin/"
poetry install
poetry run gunicorn -b "localhost:${PORT}" --timeout 120 'main:app'