hosting/act-runner/start-docker.sh
David Boreham 792ea0ad90 kind-in-docker fixes (#77)
Reviewed-on: #77
Co-authored-by: David Boreham <david@bozemanpass.com>
Co-committed-by: David Boreham <david@bozemanpass.com>
2024-01-26 01:41:54 +00:00

35 lines
960 B
Bash
Executable File

#!/bin/bash
source /opt/bash-utils/logger.sh
source /opt/bash-utils/cgroup-helper.sh
function wait_for_process () {
local max_time_wait=30
local process_name="$1"
local waited_sec=0
while ! pgrep "$process_name" >/dev/null && ((waited_sec < max_time_wait)); do
INFO "Process $process_name is not running yet. Retrying in 1 seconds"
INFO "Waited $waited_sec seconds of $max_time_wait seconds"
sleep 1
((waited_sec=waited_sec+1))
if ((waited_sec >= max_time_wait)); then
return 1
fi
done
return 0
}
# Some payloads (e.g. kind) need systemd to run, which in turn requires forking the cgroup hierarchy
configure_cgroup
INFO "Starting supervisor"
/usr/bin/supervisord -n >> /dev/null 2>&1 &
INFO "Waiting for docker to be running"
wait_for_process dockerd
if [ $? -ne 0 ]; then
ERROR "dockerd is not running after max time"
exit 1
else
INFO "dockerd is running"
fi