From 205bc8f9e657f6890c62dae8f5ceafe914f65d5f Mon Sep 17 00:00:00 2001 From: Boris Kolpackov Date: Tue, 4 Apr 2017 14:56:19 +0200 Subject: Pass CPU and RAM parameters to bbot agent --- buildos | 28 ++++++++++++++++++++-------- 1 file changed, 20 insertions(+), 8 deletions(-) diff --git a/buildos b/buildos index 2de20f9..512bf27 100755 --- a/buildos +++ b/buildos @@ -137,18 +137,18 @@ for tn in "${!toolchains[@]}"; do fi done -# Divide CPUs and memory (in kB) among the toolchains. +# Divide CPUs and RAM (in kB) among the toolchains. # # Reserve 4G of RAM for ourselves (rootfs, tmpfs). # -mem_total="$(sed -n -re 's/^MemTotal: *([0-9]+) *kB$/\1/p' # the systemd pattern machinery since each version of bbot can have its # own version of the .service file. # - sed -i -re "s/%[iI]/$tn/g" "$id/lib/systemd/system/bbot-agent@.service" + sed -i -r \ + -e "s/%[iI]/$tn/g" \ + -e "s/^(Environment=CPU)=.*/\1=$cpu_slice/" \ + -e "s/^(Environment=RAM)=.*/\1=$ram_slice/" \ + "$id/lib/systemd/system/bbot-agent@.service" + sudo ln -sf "$id/lib/systemd/system/bbot-agent@.service" \ "/usr/lib/systemd/system/bbot-agent@$tn.service" - # Start the service. + # Start the service. With Type=simple start returns as soon as the process + # has forked. To see if the service actually started we wait a bit and + # check with status. # if ! sudo systemctl start "bbot-agent@$tn"; then info "failed to start bbot-agent@$tn service" break fi + if ! sudo systemctl status "bbot-agent@$tn"; then + info "failed to start bbot-agent@$tn service" + break + fi + r=0 break done -- cgit v1.1