aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorIsmaël Bouya <ismael.bouya@normalesup.org>2021-06-26 10:07:40 +0200
committerIsmaël Bouya <ismael.bouya@normalesup.org>2021-06-26 10:07:40 +0200
commitecd9a3060bdcc4309e4fad6c046b72b880618774 (patch)
tree9e0771cb91b52a90e250a518e1efafcba0493d03
parentc20a589de267dded1c096e1c1339b5efe5156f1f (diff)
downloadNix-ecd9a3060bdcc4309e4fad6c046b72b880618774.tar.gz
Nix-ecd9a3060bdcc4309e4fad6c046b72b880618774.tar.zst
Nix-ecd9a3060bdcc4309e4fad6c046b72b880618774.zip
Make wwwrun run the python application
-rw-r--r--modules/private/buildbot/projects/denise/__init__.py9
-rw-r--r--modules/private/websites/denise/oms.nix14
2 files changed, 20 insertions, 3 deletions
diff --git a/modules/private/buildbot/projects/denise/__init__.py b/modules/private/buildbot/projects/denise/__init__.py
index 20ba913..2a19ef5 100644
--- a/modules/private/buildbot/projects/denise/__init__.py
+++ b/modules/private/buildbot/projects/denise/__init__.py
@@ -72,6 +72,13 @@ def denise_oms_factory():
72 return "/run/denise_oms_beta/gunicorn.pid" 72 return "/run/denise_oms_beta/gunicorn.pid"
73 73
74 @util.renderer 74 @util.renderer
75 def oms_systemd_service(props):
76 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
77 return "denise-oms"
78 else:
79 return "denise-oms-beta"
80
81 @util.renderer
75 def oms_url(props): 82 def oms_url(props):
76 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master": 83 if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
77 return "https://oms.syanni.eu" 84 return "https://oms.syanni.eu"
@@ -94,7 +101,7 @@ def denise_oms_factory():
94 masterdest=oms_path, 101 masterdest=oms_path,
95 url=oms_url)) 102 url=oms_url))
96 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("chmod -R a+rX %(kw:oms_path)s", oms_path=oms_path))) 103 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("chmod -R a+rX %(kw:oms_path)s", oms_path=oms_path)))
97 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("kill $(cat %(kw:oms_run_path)s)", oms_run_path=oms_run_path))) 104 factory.addStep(steps.MasterShellCommand(command=util.Interpolate("/run/wrappers/bin/sudo systemctl restart %(kw:oms_service)s.service", oms_service=oms_systemd_service)))
98 105
99 return util.BuilderConfig(name="DeniseOMS_build", workernames=["generic-worker-denise"], factory=factory) 106 return util.BuilderConfig(name="DeniseOMS_build", workernames=["generic-worker-denise"], factory=factory)
100 107
diff --git a/modules/private/websites/denise/oms.nix b/modules/private/websites/denise/oms.nix
index 18773ae..2f18037 100644
--- a/modules/private/websites/denise/oms.nix
+++ b/modules/private/websites/denise/oms.nix
@@ -38,7 +38,7 @@ in {
38 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]); 38 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
39 in 39 in
40 "${python}/bin/gunicorn -w4 -p /run/denise_oms/gunicorn.pid --bind unix:${socket} app:app"; 40 "${python}/bin/gunicorn -w4 -p /run/denise_oms/gunicorn.pid --bind unix:${socket} app:app";
41 User = "buildbot"; 41 User = "wwwrun";
42 Restart = "always"; 42 Restart = "always";
43 RestartSec = "5s"; 43 RestartSec = "5s";
44 PIDFile = "/run/denise_oms/gunicorn.pid"; 44 PIDFile = "/run/denise_oms/gunicorn.pid";
@@ -48,6 +48,16 @@ in {
48 }; 48 };
49 }; 49 };
50 50
51 security.sudo.extraRules = [
52 {
53 commands = [
54 { options = [ "NOPASSWD" ]; command = "${pkgs.systemd}/bin/systemctl restart denise-oms-beta.service"; }
55 { options = [ "NOPASSWD" ]; command = "${pkgs.systemd}/bin/systemctl restart denise-oms.service"; }
56 ];
57 users = ["buildbot"];
58 runAs = "root";
59 }
60 ];
51 services.websites.env.integration.vhostConfs.denise_oms_beta = { 61 services.websites.env.integration.vhostConfs.denise_oms_beta = {
52 certName = "denise"; 62 certName = "denise";
53 addToCerts = true; 63 addToCerts = true;
@@ -77,7 +87,7 @@ in {
77 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]); 87 python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
78 in 88 in
79 "${python}/bin/gunicorn -w4 -p /run/denise_oms_beta/gunicorn.pid --bind unix:${socket_beta} app:app"; 89 "${python}/bin/gunicorn -w4 -p /run/denise_oms_beta/gunicorn.pid --bind unix:${socket_beta} app:app";
80 User = "buildbot"; 90 User = "wwwrun";
81 Restart = "always"; 91 Restart = "always";
82 RestartSec = "5s"; 92 RestartSec = "5s";
83 PIDFile = "/run/denise_oms_beta/gunicorn.pid"; 93 PIDFile = "/run/denise_oms_beta/gunicorn.pid";