From 5e40d7944a671f154f923d614d3072374b88f560 Mon Sep 17 00:00:00 2001 From: Oscar Krause Date: Fri, 30 Dec 2022 07:33:17 +0100 Subject: [PATCH] PKGBUILD - updated service running uvicorn natively instead of calling main.py - fixed issue with not loading env variables inside to fastapi - fixed to not using "python main.py" which meant for development --- .PKGBUILD/PKGBUILD | 13 ++++++++----- .PKGBUILD/fastapi-dls.default | 5 +++++ .PKGBUILD/fastapi-dls.service | 11 ++++++----- .PKGBUILD/fastapi-dls.tmpfiles | 2 ++ 4 files changed, 21 insertions(+), 10 deletions(-) create mode 100644 .PKGBUILD/fastapi-dls.tmpfiles diff --git a/.PKGBUILD/PKGBUILD b/.PKGBUILD/PKGBUILD index f8fb48e..97d3995 100644 --- a/.PKGBUILD/PKGBUILD +++ b/.PKGBUILD/PKGBUILD @@ -1,8 +1,8 @@ -# Maintainer: samicrusader # Maintainer: Oscar Krause +# Contributor: samicrusader pkgname=fastapi-dls -pkgver=0.0 +pkgver=1.1 pkgrel=1 pkgdesc='NVIDIA DLS server implementation with FastAPI' arch=('any') @@ -13,10 +13,12 @@ provider=("$pkgname") install="$pkgname.install" source=('git+file:///builds/oscar.krause/fastapi-dls' # https://gitea.publichub.eu/oscar.krause/fastapi-dls.git "$pkgname.default" - "$pkgname.service") + "$pkgname.service" + "$pkgname.tmpfiles") sha256sums=('SKIP' - '4c07e9b627853bd4f3a398371912fc72302dac33f43e4cb7e9b79746cc9c9136' - '10cb98d64f8bf37b11a60510793c187cc664e63c895d1205781c21fa2e703f32') + 'fbd015449a30c0ae82733289a56eb98151dcfab66c91b37fe8e202e39f7a5edb' + '2719338541104c537453a65261c012dda58e1dbee99154cf4f33b526ee6ca22e' + '3dc60140c08122a8ec0e7fa7f0937eb8c1288058890ba09478420fc30ce9e30c') pkgver() { source $srcdir/$pkgname/version.env @@ -46,4 +48,5 @@ package() { install -Dm755 "$srcdir/$pkgname/app/util.py" "$pkgdir/opt/$pkgname/util.py" install -Dm644 "$srcdir/$pkgname.default" "$pkgdir/etc/default/$pkgname" install -Dm644 "$srcdir/$pkgname.service" "$pkgdir/usr/lib/systemd/system/$pkgname.service" + install -Dm644 "$srcdir/$pkgname.tmpfiles" "$pkgdir/usr/lib/tmpfiles.d/$pkgname.conf" } diff --git a/.PKGBUILD/fastapi-dls.default b/.PKGBUILD/fastapi-dls.default index 0add216..0bfb664 100644 --- a/.PKGBUILD/fastapi-dls.default +++ b/.PKGBUILD/fastapi-dls.default @@ -3,6 +3,7 @@ DEBUG=false # Where the client can find the DLS server ## DLS_URL should be a hostname +LISTEN_IP="0.0.0.0" DLS_URL="localhost.localdomain" DLS_PORT=8443 CORS_ORIGINS="https://$DLS_URL:$DLS_PORT" @@ -21,3 +22,7 @@ INSTANCE_REF="<>" # Site-wide signing keys INSTANCE_KEY_RSA="/var/lib/fastapi-dls/instance.private.pem" INSTANCE_KEY_PUB="/var/lib/fastapi-dls/instance.public.pem" + +# TLS certificate +INSTANCE_SSL_CERT="/var/lib/fastapi-dls/cert/webserver.crt" +INSTANCE_SSL_KEY="/var/lib/fastapi-dls/cert/webserver.key" diff --git a/.PKGBUILD/fastapi-dls.service b/.PKGBUILD/fastapi-dls.service index 1bca7b7..8670ab5 100644 --- a/.PKGBUILD/fastapi-dls.service +++ b/.PKGBUILD/fastapi-dls.service @@ -4,12 +4,13 @@ Documentation=https://git.collinwebdesigns.de/oscar.krause/fastapi-dls After=network.target [Service] -Type=forking +Type=simple +AmbientCapabilities=CAP_NET_BIND_SERVICE EnvironmentFile=/etc/default/fastapi-dls -ExecStart=/usr/bin/python /opt/fastapi-dls/main.py -WorkingDir=/opt/fastapi-dls +ExecStart=/usr/bin/uvicorn main:app --proxy-headers --env-file=/etc/default/fastapi-dls --host=${LISTEN_IP} --port=${DLS_PORT} --app-dir=/opt/fastapi-dls --ssl-keyfile=${INSTANCE_SSL_KEY} --ssl-certfile=${INSTANCE_SSL_CERT} Restart=on-abort -User=root +User=http +Group=http [Install] -WantedBy=multi-user.target +WantedBy=multi-user.target \ No newline at end of file diff --git a/.PKGBUILD/fastapi-dls.tmpfiles b/.PKGBUILD/fastapi-dls.tmpfiles new file mode 100644 index 0000000..a9dc351 --- /dev/null +++ b/.PKGBUILD/fastapi-dls.tmpfiles @@ -0,0 +1,2 @@ +d /var/lib/fastapi-dls 0755 http http +d /var/lib/fastapi-dls/cert 0755 http http