]> git.immae.eu Git - perso/Immae/Config/Nix.git/commitdiff
Add beta for Denise OMS
authorIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 18 Feb 2021 18:58:44 +0000 (19:58 +0100)
committerIsmaël Bouya <ismael.bouya@normalesup.org>
Thu, 18 Feb 2021 20:04:24 +0000 (21:04 +0100)
modules/private/buildbot/projects/denise/__init__.py
modules/private/websites/denise/oms.nix
nixops/secrets

index 5bd4b1af0419b1d632d34d6c06b4c9545d3b698c..20ba913002195e38bd9fd9f285b101a82d20066e 100644 (file)
@@ -15,6 +15,7 @@ class E():
     SSH_HOST_KEY      = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF"
 
     OMS_RELEASE_PATH  = "/var/lib/buildbot/outputs/denise/oms"
+    OMS_BETA_PATH     = "/var/lib/buildbot/outputs/denise/oms_beta"
     OMS_GIT_URL       = "gitolite@git.immae.eu:perso/Denise/oms"
 
     AVENTURIERS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/aventuriers"
@@ -63,16 +64,37 @@ def configure(c):
     c['builders'].append(denise_aventuriers_factory())
 
 def denise_oms_factory():
+    @util.renderer
+    def oms_run_path(props):
+        if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
+            return "/run/denise_oms/gunicorn.pid"
+        else:
+            return "/run/denise_oms_beta/gunicorn.pid"
+
+    @util.renderer
+    def oms_url(props):
+        if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
+            return "https://oms.syanni.eu"
+        else:
+            return "https://beta.oms.syanni.eu"
+
+    @util.renderer
+    def oms_path(props):
+        if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master":
+            return E.OMS_RELEASE_PATH
+        else:
+            return E.OMS_BETA_PATH
+
     factory = util.BuildFactory()
     factory.addStep(steps.Git(logEnviron=False, repourl=E.OMS_GIT_URL,
         submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(),
         sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy"))
-    factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.OMS_RELEASE_PATH)))
+    factory.addStep(steps.MasterShellCommand(command=util.Interpolate("rm -rf %(kw:oms_path)s", oms_path=oms_path)))
     factory.addStep(steps.DirectoryUpload(workersrc="../source",
-        masterdest=E.OMS_RELEASE_PATH,
-        url="https://oms.syanni.eu"))
-    factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.OMS_RELEASE_PATH)))
-    factory.addStep(steps.MasterShellCommand(command="kill $(cat /run/denise_oms/gunicorn.pid)"))
+        masterdest=oms_path,
+        url=oms_url))
+    factory.addStep(steps.MasterShellCommand(command=util.Interpolate("chmod -R a+rX %(kw:oms_path)s", oms_path=oms_path)))
+    factory.addStep(steps.MasterShellCommand(command=util.Interpolate("kill $(cat %(kw:oms_run_path)s)", oms_run_path=oms_run_path)))
 
     return util.BuilderConfig(name="DeniseOMS_build", workernames=["generic-worker-denise"], factory=factory)
 
index 2c5e90e3b33e88fa6d86394942ae2a081c7260c0..18773ae8cedfb36878bc05914a9f752182089eb1 100644 (file)
@@ -2,7 +2,9 @@
 let
   cfg = config.myServices.websites.denise.oms;
   varDir = "/var/lib/buildbot/outputs/denise/oms";
+  varDirBeta = "/var/lib/buildbot/outputs/denise/oms_beta";
   socket = "/run/denise_oms/socket.sock";
+  socket_beta = "/run/denise_oms_beta/socket.sock";
 in {
   options.myServices.websites.denise.oms.enable = lib.mkEnableOption "enable Denise's OMS website";
 
@@ -45,5 +47,44 @@ in {
         StandardError = "inherit";
       };
     };
+
+    services.websites.env.integration.vhostConfs.denise_oms_beta = {
+      certName     = "denise";
+      addToCerts   = true;
+      hosts        = [ "beta.oms.syanni.eu" ];
+      root         = null;
+      extraConfig  = [
+        ''
+        ProxyPreserveHost on
+        ProxyVia On
+        ProxyRequests Off
+        ProxyPassMatch ^/.well-known/acme-challenge !
+        ProxyPass / unix://${socket_beta}|http://beta.oms.syanni.eu/
+        ProxyPassReverse / unix://${socket_beta}|http://beta.oms.syanni.eu/
+          ''
+      ];
+    };
+
+    systemd.services.denise-oms-beta = {
+      description = "Denise OMS beta website";
+      after = [ "network.target" ];
+      wantedBy = [ "multi-user.target" ];
+
+      serviceConfig = {
+        Type = "simple";
+        WorkingDirectory = varDirBeta;
+        ExecStart = let
+          python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]);
+        in
+          "${python}/bin/gunicorn -w4 -p /run/denise_oms_beta/gunicorn.pid --bind unix:${socket_beta} app:app";
+        User = "buildbot";
+        Restart = "always";
+        RestartSec = "5s";
+        PIDFile = "/run/denise_oms_beta/gunicorn.pid";
+        RuntimeDirectory = "denise_oms_beta";
+        StandardOutput = "journal";
+        StandardError = "inherit";
+      };
+    };
   };
 }
index 9f0dec5a2040820a1ce8859838f92499babefdc8..65b942ba13daa40fc45fa34d58676c213b5bad87 160000 (submodule)
@@ -1 +1 @@
-Subproject commit 9f0dec5a2040820a1ce8859838f92499babefdc8
+Subproject commit 65b942ba13daa40fc45fa34d58676c213b5bad87