make worker name configurable
This commit is contained in:
parent
13323c8443
commit
cb1e2640cd
|
@ -11,7 +11,7 @@ from twisted.python import components
|
|||
|
||||
def require_env(key: str) -> str:
|
||||
val = os.environ.get(key)
|
||||
assert val is not None, "val is not set"
|
||||
assert val is not None, f"{key} environment variable is not set"
|
||||
return val
|
||||
|
||||
|
||||
|
@ -22,6 +22,9 @@ class WorkerConfig:
|
|||
.read_text()
|
||||
.rstrip("\r\n")
|
||||
)
|
||||
worker_name: str = field(
|
||||
default_factory=lambda: os.environ.get("WORKER_NAME", socket.gethostname())
|
||||
)
|
||||
worker_count: int = int(
|
||||
os.environ.get("WORKER_COUNT", str(multiprocessing.cpu_count())),
|
||||
)
|
||||
|
@ -39,8 +42,7 @@ def setup_worker(
|
|||
basedir = config.buildbot_dir.parent / f"{config.buildbot_dir.name}-{builder_id:03}"
|
||||
basedir.mkdir(parents=True, exist_ok=True, mode=0o700)
|
||||
|
||||
hostname = socket.gethostname()
|
||||
workername = f"{hostname}-{builder_id:03}"
|
||||
workername = f"{config.worker_name}-{builder_id:03}"
|
||||
keepalive = 600
|
||||
umask = None
|
||||
maxdelay = 300
|
||||
|
|
|
@ -13,6 +13,11 @@ in
|
|||
options = {
|
||||
services.buildbot-nix.worker = {
|
||||
enable = lib.mkEnableOption "buildbot-worker";
|
||||
name = lib.mkOption {
|
||||
type = lib.types.str;
|
||||
default = config.networking.hostName;
|
||||
description = "The buildbot worker name.";
|
||||
};
|
||||
package = lib.mkOption {
|
||||
type = lib.types.package;
|
||||
default = pkgs.buildbot-worker;
|
||||
|
@ -70,7 +75,10 @@ in
|
|||
OOMPolicy = "continue";
|
||||
|
||||
LoadCredential = [ "worker-password-file:${cfg.workerPasswordFile}" ];
|
||||
Environment = [ "WORKER_PASSWORD_FILE=%d/worker-password-file" ];
|
||||
Environment = [
|
||||
"WORKER_PASSWORD_FILE=%d/worker-password-file"
|
||||
"WORKER_NAME=${cfg.name}"
|
||||
];
|
||||
Type = "simple";
|
||||
User = "buildbot-worker";
|
||||
Group = "buildbot-worker";
|
||||
|
|
Loading…
Reference in a new issue