🗃️ Committing everything that changed 🗃️

rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh
This commit is contained in:
casjay 2024-08-11 14:55:44 -04:00
parent e599a9210b
commit 827f0aa206
Signed by untrusted user who does not match committer: jason
GPG Key ID: 1AB309F42A764145

View File

@ -239,7 +239,6 @@ RUNNER_HOSTNAME="${INSTANCE_HOSTNAME:-http://127.0.0.1:8000}"
CONTAINER_IP4_ADDRESS="${CONTAINER_IP4_ADDRESS}"
EOF
fi
if [ ! -f "$CONF_DIR/runners" ]; then
for runner in "$CONF_DIR/reg"/*.reg; do
exitStatus=0
RUNNER_NAME="$(basename "${runner//.reg/}")"
@ -247,6 +246,7 @@ EOF
[ -f "$runner" ] && . "$runner"
[ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && break
RUNNER_HOME="${RUNNER_HOME:-$CONF_DIR/multi/$RUNNER_NAME}"
mkdir -p "$RUNNER_HOME"
if [ -z "$RUNNER_AUTH_TOKEN" ]; then
[ -f "$CONF_DIR/tokens/system" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/system")"
[ -f "$CONF_DIR/tokens/$RUNNER_NAME" ] && RUNNER_AUTH_TOKEN="$(<"$CONF_DIR/tokens/$RUNNER_NAME")" || { [ -n "$SYS_AUTH_TOKEN" ] && echo "$SYS_AUTH_TOKEN" >"$CONF_DIR/tokens/$RUNNER_NAME"; }
@ -257,15 +257,15 @@ EOF
sleep 120
else
echo "RUNNER_AUTH_TOKEN has been set: trying to register $RUNNER_NAME"
if [ ! -f "$RUNNER_HOME/runners" ]; then
cp -Rf "$CONF_DIR/multi.yaml" "$RUNNER_HOME/$RUNNER_NAME.yaml"
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_NAME.yaml"
act_runner register --config "$RUNNER_HOME/$RUNNER_NAME.yaml" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "http://$CONTAINER_IP4_ADDRESS:8000" --token "$RUNNER_AUTH_TOKEN" --no-interactive && exitStatus=0 || exitStatus=1
echo "$!" >"$RUN_DIR/act_runner.$RUNNER_NAME.pid"
if [ $exitStatus -eq 0 ]; then
exitStatus=0
mv -fv "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
cp -Rf "$CONF_DIR/multi.yaml" "$RUNNER_HOME/$RUNNER_NAME.yaml"
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_NAME.yaml"
cp -Rf "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$RUNNER_HOME"
act_runner daemon --config $RUNNER_HOME/$RUNNER_NAME.yaml
break
else
[ -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid" ] && rm -f "$RUN_DIR/act_runner.$RUNNER_NAME.pid"
@ -273,9 +273,9 @@ EOF
sleep 20
fi
fi
fi
done
done 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null
fi
echo "$$" >"$RUN_DIR/act_runner.pid"
echo "$(date)" >"$CONF_DIR/.runner"
return $exitStatus
@ -363,6 +363,13 @@ __post_execute() {
# show message
__banner "$postMessageST"
# commands to execute
for multi in "$CONF_DIR/multi"/*; do
name="$(basename "$multi")"
if [ -f "$$multi/$name.yaml" ] && [ -f "$multi/runners" ]; then
act_runner daemon --config $multi/$name.yaml
fi
done
act_runner cache-server --config $CONF_DIR/daemon.yaml -s 0.0.0.0 -p $SERVICE_PORT 2>>/dev/stderr | tee -a -p "$LOG_DIR/act_runner_cache.log" &
execPid=$!
sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$" && return 0 || return 2