forked from DGNum/infrastructure
feat(kadenios): Add management script
This commit is contained in:
parent
954ba45281
commit
1bf5ad93a2
1 changed files with 15 additions and 2 deletions
|
@ -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
|
||||
'';
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue