diff --git a/machines/web02/kadenios/default.nix b/machines/web02/kadenios/default.nix index 3a544ef..d3b03ab 100644 --- a/machines/web02/kadenios/default.nix +++ b/machines/web02/kadenios/default.nix @@ -50,6 +50,19 @@ let ps.loadcredential ]); + manage = pkgs.writeShellApplication { + name = "kadenios-manage"; + + runtimeInputs = [ pythonEnv ]; + + text = '' + MainPID=0 + eval "$(${lib.getExe' config.systemd.package "systemctl"} show -pMainPID django-kadenios.service)" + + ${lib.getExe' pkgs.util-linux "nsenter"} -e -a -t "$MainPID" -G follow -S follow python ${sources.kadenios}/manage.py "$@" + ''; + }; + staticDrv = pkgs.stdenv.mkDerivation { name = "kadenios-static"; @@ -88,6 +101,7 @@ let in { + environment.systemPackages = [ manage ]; systemd.services = { django-kadenios = { description = "ENS simple voting server"; @@ -105,7 +119,6 @@ in }; StateDirectory = "django-kadenios"; User = "kadenios"; - WorkingDirectory = sources.kadenios; }; inherit environment; @@ -113,7 +126,7 @@ in path = [ pythonEnv ]; script = '' - python3 manage.py migrate + python3 ${sources.kadenios}/manage.py migrate gunicorn app.wsgi --pythonpath ${sources.kadenios} -b 127.0.0.1:${builtins.toString port} --workers=2 --threads=4 ''; };