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"
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)
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";
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";
+ };
+ };
};
}