#!/bin/sh

set -eu

children=
skip_arch_list="$(./bin/debci config --values-only arch_skip_list)"
for arch in $(./bin/debci config --values-only arch_list); do
  skip_arch=no
  for skip in $skip_arch_list; do
    if [ "${arch}" = "${skip}" ]; then
      skip_arch=yes
      break
    fi
  done
  if [ "${skip_arch}" = yes ]; then
    continue
  fi
  for backend in $(./bin/debci config --values-only backend_list); do
    ./bin/debci worker --arch="${arch}" --backend="${backend}" &
    children="${children} $!"
  done
done
trap "kill ${children}" INT TERM EXIT
sleep infinity
