[Unit]
Description=divbench benchmarking setup

[Service]
Restart=always
RestartSec=15
Delegate=true
CPUAccounting=true
MemoryAccounting=true
ExecStart=/bin/bash -c '\
set -ex;\
SLICE=`grep memory: /proc/$$$$/cgroup | cut -f3 -d:`; \
chown bench /sys/fs/cgroup/memory/$$SLICE/memory.limit_in_bytes; \
chown bench /sys/fs/cgroup/memory/$$SLICE/memory.memsw.limit_in_bytes; \
sudo -u bench /srv/bench/bench-run.sh'
KillMode=control-group
KillSignal=SIGTERM

[Install]
WantedBy=multi-user.target
