diff options
author | Boris Kolpackov <boris@codesynthesis.com> | 2017-04-04 14:56:19 +0200 |
---|---|---|
committer | Boris Kolpackov <boris@codesynthesis.com> | 2017-04-04 14:56:19 +0200 |
commit | 205bc8f9e657f6890c62dae8f5ceafe914f65d5f (patch) | |
tree | b8c78b4261321ada5341e026b83979e0206b800f | |
parent | 1fbd27f288cf31625cff567788aaa0be66caffbd (diff) |
Pass CPU and RAM parameters to bbot agent
-rwxr-xr-x | buildos | 28 |
1 files changed, 20 insertions, 8 deletions
@@ -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' </proc/meminfo)" +ram_total="$(sed -n -re 's/^MemTotal: *([0-9]+) *kB$/\1/p' </proc/meminfo)" cpu_total="$(lscpu | sed -n -re 's/^CPU\(s\): *([0-9]+)$/\1/p')" -mem_slice=$(("$mem_total" - 4 * 1024 * 1024)) +ram_slice=$(("$ram_total" - 4 * 1024 * 1024)) cpu_slice="$cpu_total" if [ "${#toolchain_names[@]}" -gt 1 ]; then - mem_slice=$(("$mem_slice" / "${#toolchain_names[@]}")) + ram_slice=$(("$ram_slice" / "${#toolchain_names[@]}")) cpu_slice=$(("$cpu_slice" / "${#toolchain_names[@]}")) if [ "$cpu_slice" -eq 0 ]; then @@ -163,8 +163,8 @@ function print () echo "cpu_total: $cpu_total" echo "cpu_slice: $cpu_slice" - echo "mem_total: $mem_total kB" - echo "mem_slice: $mem_slice kB" + echo "ram_total: $ram_total kB" + echo "ram_slice: $ram_slice kB" echo echo "buildid: $buildid" @@ -600,17 +600,29 @@ function bb_start () # <toolchain-name> # 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 |