| ... | @@ -15,6 +15,7 @@ let | ... | @@ -15,6 +15,7 @@ let |
| 15 | exec ${pkgs.podman}/bin/podman --root=${root}/containers/storage --runroot=/run/knife-linux/containers "$@" | 15 | exec ${pkgs.podman}/bin/podman --root=${root}/containers/storage --runroot=/run/knife-linux/containers "$@" |
| 16 | ''; | 16 | ''; |
| 17 | run = "${podman}/bin/knife-linux-podman"; | 17 | run = "${podman}/bin/knife-linux-podman"; |
| | 18 | ccd = "8-15,24-31"; |
| 18 | in | 19 | in |
| 19 | { | 20 | { |
| 20 | environment.systemPackages = [ podman ]; | 21 | environment.systemPackages = [ podman ]; |
| ... | @@ -38,14 +39,23 @@ in | ... | @@ -38,14 +39,23 @@ in |
| 38 | run "run --rm --replace --name=knife-linux --pull=never" | 39 | run "run --rm --replace --name=knife-linux --pull=never" |
| 39 | "--sdnotify=conmon --cgroups=no-conmon --log-driver=journald --init --hostname=knife-linux" | 40 | "--sdnotify=conmon --cgroups=no-conmon --log-driver=journald --init --hostname=knife-linux" |
| 40 | "--user=${uid}:${gid} --umask=0077 --cap-drop=ALL --security-opt=no-new-privileges" | 41 | "--user=${uid}:${gid} --umask=0077 --cap-drop=ALL --security-opt=no-new-privileges" |
| 41 | # A low weight rather than a CPU quota: an exhausted quota freezes the Knife server too. | 42 | "--memory=32g --pids-limit=32768 --shm-size=2g --network=podman" |
| 42 | "--memory=32g --cpu-shares=1024 --pids-limit=32768 --shm-size=2g --network=podman" | | |
| 43 | "--volume=${root}/home:/home/clo" | 43 | "--volume=${root}/home:/home/clo" |
| 44 | "--volume=${sandbox}:/Volumes/Code" | 44 | "--volume=${sandbox}:/Volumes/Code" |
| 45 | "--volume=/opt/studio-project-store/current/bin/jj-real:/usr/local/bin/jj:ro" | 45 | "--volume=/opt/studio-project-store/current/bin/jj-real:/usr/local/bin/jj:ro" |
| 46 | "--device=/dev/kvm" | 46 | "--device=/dev/kvm" |
| 47 | "localhost/knife-linux" | 47 | "localhost/knife-linux" |
| 48 | ]; | 48 | ]; |
| | 49 | # Agents get the second CCD to themselves and the host keeps the first. A partition |
| | 50 | # rather than a CPU quota: an exhausted quota freezes the Knife server with the builds. |
| | 51 | ExecStartPost = "-" + pkgs.writeShellScript "knife-linux-cpus" '' |
| | 52 | set -e |
| | 53 | scope=/sys/fs/cgroup$(${run} inspect --format '{{.State.CgroupPath}}' knife-linux) |
| | 54 | echo ${ccd} > /sys/fs/cgroup/machine.slice/cpuset.cpus.exclusive |
| | 55 | echo ${ccd} > $scope/cpuset.cpus.exclusive |
| | 56 | echo ${ccd} > $scope/cpuset.cpus |
| | 57 | echo root > $scope/cpuset.cpus.partition |
| | 58 | ''; |
| 49 | ExecStop = "${run} stop --ignore --time=90 knife-linux"; | 59 | ExecStop = "${run} stop --ignore --time=90 knife-linux"; |
| 50 | ExecStopPost = "${run} rm --ignore --force knife-linux"; | 60 | ExecStopPost = "${run} rm --ignore --force knife-linux"; |
| 51 | KillMode = "mixed"; | 61 | KillMode = "mixed"; |