diff options
Diffstat (limited to 'modules/private')
-rw-r--r-- | modules/private/buildbot/projects/denise/__init__.py | 32 | ||||
-rw-r--r-- | modules/private/websites/denise/oms.nix | 41 |
2 files changed, 68 insertions, 5 deletions
diff --git a/modules/private/buildbot/projects/denise/__init__.py b/modules/private/buildbot/projects/denise/__init__.py index 5bd4b1a..20ba913 100644 --- a/modules/private/buildbot/projects/denise/__init__.py +++ b/modules/private/buildbot/projects/denise/__init__.py | |||
@@ -15,6 +15,7 @@ class E(): | |||
15 | SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF" | 15 | SSH_HOST_KEY = "ssh-ed25519 AAAAC3NzaC1lZDI1NTE5AAAAIIFbhFTl2A2RJn5L51yxJM4XfCS2ZaiSX/jo9jFSdghF" |
16 | 16 | ||
17 | OMS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/oms" | 17 | OMS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/oms" |
18 | OMS_BETA_PATH = "/var/lib/buildbot/outputs/denise/oms_beta" | ||
18 | OMS_GIT_URL = "gitolite@git.immae.eu:perso/Denise/oms" | 19 | OMS_GIT_URL = "gitolite@git.immae.eu:perso/Denise/oms" |
19 | 20 | ||
20 | AVENTURIERS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/aventuriers" | 21 | AVENTURIERS_RELEASE_PATH = "/var/lib/buildbot/outputs/denise/aventuriers" |
@@ -63,16 +64,37 @@ def configure(c): | |||
63 | c['builders'].append(denise_aventuriers_factory()) | 64 | c['builders'].append(denise_aventuriers_factory()) |
64 | 65 | ||
65 | def denise_oms_factory(): | 66 | def denise_oms_factory(): |
67 | @util.renderer | ||
68 | def oms_run_path(props): | ||
69 | if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master": | ||
70 | return "/run/denise_oms/gunicorn.pid" | ||
71 | else: | ||
72 | return "/run/denise_oms_beta/gunicorn.pid" | ||
73 | |||
74 | @util.renderer | ||
75 | def oms_url(props): | ||
76 | if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master": | ||
77 | return "https://oms.syanni.eu" | ||
78 | else: | ||
79 | return "https://beta.oms.syanni.eu" | ||
80 | |||
81 | @util.renderer | ||
82 | def oms_path(props): | ||
83 | if props.hasProperty("branch") and len(props["branch"]) > 0 and props["branch"] == "master": | ||
84 | return E.OMS_RELEASE_PATH | ||
85 | else: | ||
86 | return E.OMS_BETA_PATH | ||
87 | |||
66 | factory = util.BuildFactory() | 88 | factory = util.BuildFactory() |
67 | factory.addStep(steps.Git(logEnviron=False, repourl=E.OMS_GIT_URL, | 89 | factory.addStep(steps.Git(logEnviron=False, repourl=E.OMS_GIT_URL, |
68 | submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), | 90 | submodules=True, sshPrivateKey=open(E.SSH_KEY_PATH).read().rstrip(), |
69 | sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) | 91 | sshHostKey=E.SSH_HOST_KEY, mode="full", method="copy")) |
70 | factory.addStep(steps.MasterShellCommand(command="rm -rf {}".format(E.OMS_RELEASE_PATH))) | 92 | factory.addStep(steps.MasterShellCommand(command=util.Interpolate("rm -rf %(kw:oms_path)s", oms_path=oms_path))) |
71 | factory.addStep(steps.DirectoryUpload(workersrc="../source", | 93 | factory.addStep(steps.DirectoryUpload(workersrc="../source", |
72 | masterdest=E.OMS_RELEASE_PATH, | 94 | masterdest=oms_path, |
73 | url="https://oms.syanni.eu")) | 95 | url=oms_url)) |
74 | factory.addStep(steps.MasterShellCommand(command="chmod -R a+rX {}".format(E.OMS_RELEASE_PATH))) | 96 | factory.addStep(steps.MasterShellCommand(command=util.Interpolate("chmod -R a+rX %(kw:oms_path)s", oms_path=oms_path))) |
75 | factory.addStep(steps.MasterShellCommand(command="kill $(cat /run/denise_oms/gunicorn.pid)")) | 97 | factory.addStep(steps.MasterShellCommand(command=util.Interpolate("kill $(cat %(kw:oms_run_path)s)", oms_run_path=oms_run_path))) |
76 | 98 | ||
77 | return util.BuilderConfig(name="DeniseOMS_build", workernames=["generic-worker-denise"], factory=factory) | 99 | return util.BuilderConfig(name="DeniseOMS_build", workernames=["generic-worker-denise"], factory=factory) |
78 | 100 | ||
diff --git a/modules/private/websites/denise/oms.nix b/modules/private/websites/denise/oms.nix index 2c5e90e..18773ae 100644 --- a/modules/private/websites/denise/oms.nix +++ b/modules/private/websites/denise/oms.nix | |||
@@ -2,7 +2,9 @@ | |||
2 | let | 2 | let |
3 | cfg = config.myServices.websites.denise.oms; | 3 | cfg = config.myServices.websites.denise.oms; |
4 | varDir = "/var/lib/buildbot/outputs/denise/oms"; | 4 | varDir = "/var/lib/buildbot/outputs/denise/oms"; |
5 | varDirBeta = "/var/lib/buildbot/outputs/denise/oms_beta"; | ||
5 | socket = "/run/denise_oms/socket.sock"; | 6 | socket = "/run/denise_oms/socket.sock"; |
7 | socket_beta = "/run/denise_oms_beta/socket.sock"; | ||
6 | in { | 8 | in { |
7 | options.myServices.websites.denise.oms.enable = lib.mkEnableOption "enable Denise's OMS website"; | 9 | options.myServices.websites.denise.oms.enable = lib.mkEnableOption "enable Denise's OMS website"; |
8 | 10 | ||
@@ -45,5 +47,44 @@ in { | |||
45 | StandardError = "inherit"; | 47 | StandardError = "inherit"; |
46 | }; | 48 | }; |
47 | }; | 49 | }; |
50 | |||
51 | services.websites.env.integration.vhostConfs.denise_oms_beta = { | ||
52 | certName = "denise"; | ||
53 | addToCerts = true; | ||
54 | hosts = [ "beta.oms.syanni.eu" ]; | ||
55 | root = null; | ||
56 | extraConfig = [ | ||
57 | '' | ||
58 | ProxyPreserveHost on | ||
59 | ProxyVia On | ||
60 | ProxyRequests Off | ||
61 | ProxyPassMatch ^/.well-known/acme-challenge ! | ||
62 | ProxyPass / unix://${socket_beta}|http://beta.oms.syanni.eu/ | ||
63 | ProxyPassReverse / unix://${socket_beta}|http://beta.oms.syanni.eu/ | ||
64 | '' | ||
65 | ]; | ||
66 | }; | ||
67 | |||
68 | systemd.services.denise-oms-beta = { | ||
69 | description = "Denise OMS beta website"; | ||
70 | after = [ "network.target" ]; | ||
71 | wantedBy = [ "multi-user.target" ]; | ||
72 | |||
73 | serviceConfig = { | ||
74 | Type = "simple"; | ||
75 | WorkingDirectory = varDirBeta; | ||
76 | ExecStart = let | ||
77 | python = pkgs.python3.withPackages (p: [ p.gunicorn p.flask p.matplotlib p.unidecode ]); | ||
78 | in | ||
79 | "${python}/bin/gunicorn -w4 -p /run/denise_oms_beta/gunicorn.pid --bind unix:${socket_beta} app:app"; | ||
80 | User = "buildbot"; | ||
81 | Restart = "always"; | ||
82 | RestartSec = "5s"; | ||
83 | PIDFile = "/run/denise_oms_beta/gunicorn.pid"; | ||
84 | RuntimeDirectory = "denise_oms_beta"; | ||
85 | StandardOutput = "journal"; | ||
86 | StandardError = "inherit"; | ||
87 | }; | ||
88 | }; | ||
48 | }; | 89 | }; |
49 | } | 90 | } |