Add deployment scripts
We add a rudimentary deployment setup based on gunicorn and systemd.
This commit is contained in:
parent
2daf6ab8e2
commit
682b538e16
5 changed files with 53 additions and 2 deletions
28
dist/elig-test.service
vendored
Normal file
28
dist/elig-test.service
vendored
Normal file
|
@ -0,0 +1,28 @@
|
||||||
|
[Unit]
|
||||||
|
After=network.target
|
||||||
|
WantedBy=default.target
|
||||||
|
|
||||||
|
[Service]
|
||||||
|
Environment="PORT=6666"
|
||||||
|
# /etc/ftth-elig/conf.ini
|
||||||
|
ConfigurationDirectory=ftth-elig
|
||||||
|
WorkingDirectory="/srv/www/Axione-FTTH-Test/"
|
||||||
|
ExecStart="./startGunicornService"
|
||||||
|
User=ftthTest
|
||||||
|
Group=ftthTest
|
||||||
|
Restart=on-failure
|
||||||
|
RestartSec=30
|
||||||
|
|
||||||
|
# Sandboxing
|
||||||
|
ProtectSystem=strict
|
||||||
|
ProtectHome=tmpfs
|
||||||
|
PrivateTmp=true
|
||||||
|
PrivateDevices=true
|
||||||
|
PrivateIPC=true
|
||||||
|
ProtectClock=true
|
||||||
|
ProtectKernelTunables=true
|
||||||
|
ProtectKernelModules=true
|
||||||
|
ProtectKernelLogs=true
|
||||||
|
ProtectControlGroups=true
|
||||||
|
RestrictAddressFamilies=AF_INET
|
||||||
|
RestrictRealtime=true
|
19
poetry.lock
generated
19
poetry.lock
generated
|
@ -62,6 +62,20 @@ Werkzeug = ">=2.0"
|
||||||
async = ["asgiref (>=3.2)"]
|
async = ["asgiref (>=3.2)"]
|
||||||
dotenv = ["python-dotenv"]
|
dotenv = ["python-dotenv"]
|
||||||
|
|
||||||
|
[[package]]
|
||||||
|
name = "gunicorn"
|
||||||
|
version = "20.1.0"
|
||||||
|
description = "WSGI HTTP Server for UNIX"
|
||||||
|
category = "main"
|
||||||
|
optional = false
|
||||||
|
python-versions = ">=3.5"
|
||||||
|
|
||||||
|
[package.extras]
|
||||||
|
eventlet = ["eventlet (>=0.24.1)"]
|
||||||
|
gevent = ["gevent (>=1.4.0)"]
|
||||||
|
setproctitle = ["setproctitle"]
|
||||||
|
tornado = ["tornado (>=0.2)"]
|
||||||
|
|
||||||
[[package]]
|
[[package]]
|
||||||
name = "itsdangerous"
|
name = "itsdangerous"
|
||||||
version = "2.0.1"
|
version = "2.0.1"
|
||||||
|
@ -183,7 +197,7 @@ watchdog = ["watchdog"]
|
||||||
[metadata]
|
[metadata]
|
||||||
lock-version = "1.1"
|
lock-version = "1.1"
|
||||||
python-versions = "^3.8"
|
python-versions = "^3.8"
|
||||||
content-hash = "a0b053d03d5dab404be204f92db3efc73ce6d66ed491318060c5ede1036c4c12"
|
content-hash = "2e09ffd1a733b1eebc75fcc481e28791601a142256ce45ad97f71abe520e428c"
|
||||||
|
|
||||||
[metadata.files]
|
[metadata.files]
|
||||||
black = [
|
black = [
|
||||||
|
@ -202,6 +216,9 @@ flask = [
|
||||||
{file = "Flask-2.0.2-py3-none-any.whl", hash = "sha256:cb90f62f1d8e4dc4621f52106613488b5ba826b2e1e10a33eac92f723093ab6a"},
|
{file = "Flask-2.0.2-py3-none-any.whl", hash = "sha256:cb90f62f1d8e4dc4621f52106613488b5ba826b2e1e10a33eac92f723093ab6a"},
|
||||||
{file = "Flask-2.0.2.tar.gz", hash = "sha256:7b2fb8e934ddd50731893bdcdb00fc8c0315916f9fcd50d22c7cc1a95ab634e2"},
|
{file = "Flask-2.0.2.tar.gz", hash = "sha256:7b2fb8e934ddd50731893bdcdb00fc8c0315916f9fcd50d22c7cc1a95ab634e2"},
|
||||||
]
|
]
|
||||||
|
gunicorn = [
|
||||||
|
{file = "gunicorn-20.1.0.tar.gz", hash = "sha256:e0a968b5ba15f8a328fdfd7ab1fcb5af4470c28aaf7e55df02a99bc13138e6e8"},
|
||||||
|
]
|
||||||
itsdangerous = [
|
itsdangerous = [
|
||||||
{file = "itsdangerous-2.0.1-py3-none-any.whl", hash = "sha256:5174094b9637652bdb841a3029700391451bd092ba3db90600dea710ba28e97c"},
|
{file = "itsdangerous-2.0.1-py3-none-any.whl", hash = "sha256:5174094b9637652bdb841a3029700391451bd092ba3db90600dea710ba28e97c"},
|
||||||
{file = "itsdangerous-2.0.1.tar.gz", hash = "sha256:9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0"},
|
{file = "itsdangerous-2.0.1.tar.gz", hash = "sha256:9e724d68fc22902a1435351f84c3fb8623f303fffcc566a4cb952df8c572cff0"},
|
||||||
|
|
|
@ -7,6 +7,7 @@ authors = ["Félix Baylac-Jacqué <felix@alternativebit.fr>"]
|
||||||
[tool.poetry.dependencies]
|
[tool.poetry.dependencies]
|
||||||
python = "^3.8"
|
python = "^3.8"
|
||||||
Flask = "^2.0.0"
|
Flask = "^2.0.0"
|
||||||
|
gunicorn = "^20.1.0"
|
||||||
|
|
||||||
[tool.poetry.dev-dependencies]
|
[tool.poetry.dev-dependencies]
|
||||||
mypy = "^0.910"
|
mypy = "^0.910"
|
||||||
|
|
5
startGunicornService
Executable file
5
startGunicornService
Executable file
|
@ -0,0 +1,5 @@
|
||||||
|
#!/usr/bin/env bash
|
||||||
|
|
||||||
|
set -euo pipefail
|
||||||
|
|
||||||
|
poetry run gunicorn -b "localhost:${PORT}" --timeout 120 'webapp.app'
|
|
@ -5,7 +5,7 @@ from axione_api.config import parse_config
|
||||||
from axione_api.api import query_axione_pto, parse_response
|
from axione_api.api import query_axione_pto, parse_response
|
||||||
|
|
||||||
def load_config():
|
def load_config():
|
||||||
cfg_path = os.environ.get("CONFIG", "/etc/axione-elig-test.ini")
|
cfg_path = os.environ.get("CONFIG", "/etc/ftth-elig/conf.ini")
|
||||||
print(f'Reading the "{cfg_path}" config file')
|
print(f'Reading the "{cfg_path}" config file')
|
||||||
cfg = parse_config(cfg_path)
|
cfg = parse_config(cfg_path)
|
||||||
cfg.debug = True if "DEBUG" in os.environ else False
|
cfg.debug = True if "DEBUG" in os.environ else False
|
||||||
|
|
Loading…
Reference in a new issue