mirror of
https://github.com/casjaysdevdocker/gitea
synced 2024-11-21 05:23:05 -05:00
🗃️ Committing everything that changed 🗃️
Some checks failed
release-tag / release-image (push) Failing after 13s
Some checks failed
release-tag / release-image (push) Failing after 13s
rootfs/tmp/etc/act_runner/cache_server.yaml rootfs/tmp/etc/act_runner/default_config.yaml rootfs/usr/local/etc/docker/init.d/zz-act_runner.sh
This commit is contained in:
parent
d9640b7e4e
commit
26a5cc313c
@ -1,9 +1,8 @@
|
||||
log:
|
||||
# The level of logging, can be trace, debug, info, warn, error, fatal
|
||||
level: info
|
||||
level: warn
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
dir: '/data/act_runner/cache'
|
||||
# host: '0.0.0.0'
|
||||
# port: REPLACE_RUNNER_CACHE_PORT
|
||||
dir: 'REPLACE_RUNNER_CACHE_DIR'
|
||||
host: '0.0.0.0'
|
||||
port: REPLACE_RUNNER_CACHE_PORT
|
||||
|
@ -1,7 +1,7 @@
|
||||
# Config for act_runner daemon
|
||||
log:
|
||||
# The level of logging, can be trace, debug, info, warn, error, fatal
|
||||
level: info
|
||||
level: warn
|
||||
|
||||
host:
|
||||
# The parent directory of a job's working directory.
|
||||
@ -11,7 +11,7 @@ runner:
|
||||
# Where to store the registration result.
|
||||
file: REPLACE_RUNNER_HOME/runners
|
||||
# Execute how many tasks concurrently at the same time.
|
||||
capacity: 1
|
||||
capacity: 4
|
||||
# Extra environment variables to run jobs.
|
||||
envs:
|
||||
A_TEST_ENV_NAME_1: a_test_env_value_1
|
||||
@ -67,6 +67,4 @@ container:
|
||||
|
||||
cache:
|
||||
enabled: true
|
||||
#host: ''
|
||||
#port: ''
|
||||
external_server: 'http://REPLACE_RUNNER_CACHE_HOST:REPLACE_RUNNER_CACHE_PORT/'
|
||||
|
@ -262,112 +262,17 @@ exit \$exitStatus
|
||||
|
||||
EOF
|
||||
fi
|
||||
if [ ! -f "$CONF_DIR/reg/runner-1.reg" ]; then
|
||||
cat <<EOF >"$CONF_DIR/reg/runner-1.reg"
|
||||
# Settings for the default gitea runner
|
||||
RUNNER_NAME="runner-1"
|
||||
RUNNER_HOME="$RUNNER_MULTI_DIR/\$RUNNER_NAME"
|
||||
RUNNER_HOSTNAME="http://${INSTANCE_HOSTNAME:-$RUNNER_IP_ADDRESS:$GITEA_PORT}"
|
||||
RUNNER_REGISTER_URL="http://$RUNNER_IP_ADDRESS:$GITEA_PORT"
|
||||
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
|
||||
RUNNER_LABELS="$RUNNER_LABELS"
|
||||
|
||||
EOF
|
||||
fi
|
||||
if [ ! -f "$CONF_DIR/reg/runner-2.reg" ]; then
|
||||
cat <<EOF >"$CONF_DIR/reg/runner-2.reg"
|
||||
# Settings for the default local runner
|
||||
RUNNER_NAME="runner-2"
|
||||
RUNNER_HOME="$RUNNER_MULTI_DIR/\$RUNNER_NAME"
|
||||
RUNNER_HOSTNAME="http://${INSTANCE_HOSTNAME:-$RUNNER_IP_ADDRESS:$GITEA_PORT}"
|
||||
RUNNER_REGISTER_URL="http://$RUNNER_IP_ADDRESS:$GITEA_PORT"
|
||||
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$SYS_AUTH_TOKEN}"
|
||||
RUNNER_LABELS="$RUNNER_LABELS"
|
||||
|
||||
EOF
|
||||
fi
|
||||
chmod -Rf 755 "$CONF_DIR/reg"/*
|
||||
#
|
||||
mkdir -p "$RUNNER_DEFAULT_HOME" "$TMP_DIR/runners/gitea"
|
||||
[ -f "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME" ] || copy "$RUNNER_CONFIG_DEFAULT" "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME"
|
||||
if [ ! -f "$RUNNER_DEFAULT_HOME/runners" ] && [ -n "$SYS_AUTH_TOKEN" ] && [ -f "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME" ]; then
|
||||
echo "creating gitea in $RUNNER_DEFAULT_HOME and registering with http://$INSTANCE_HOSTNAME"
|
||||
echo "creating gitea runner in $RUNNER_DEFAULT_HOME and registering with http://$INSTANCE_HOSTNAME"
|
||||
__replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/runners/gitea" "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_HOME" "$RUNNER_DEFAULT_HOME" "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_CACHE_HOST" "$RUNNER_CACHE_HOST" "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_CACHE_PORT" "$RUNNER_CACHE_PORT" "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME"
|
||||
act_runner register --config "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME" --labels "$RUNNER_LABELS" --name "gitea" --instance "http://$RUNNER_IP_ADDRESS:$GITEA_PORT" --token "$SYS_AUTH_TOKEN" --no-interactive 2>/dev/stdout >>"$RUNNER_LOG_FILE" &
|
||||
fi
|
||||
for runner in "$CONF_DIR/reg"/*.reg; do
|
||||
echo "Setting up $runner"
|
||||
if [ -f "$runner" ]; then
|
||||
. "$runner"
|
||||
while :; do
|
||||
RUNNER_LABELS="${RUNNER_LABELS:-act_runner}"
|
||||
RUNNER_NAME="${RUNNER_NAME:-$(basename "${runner//.reg/}")}"
|
||||
RUNNER_HOME="${RUNNER_HOME:-$RUNNER_MULTI_DIR/$RUNNER_NAME}"
|
||||
RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$(__gen_auth_token)}"
|
||||
RUNNER_HOSTNAME="${RUNNER_HOSTNAME:-http://$INSTANCE_HOSTNAME}"
|
||||
RUNNER_REGISTER_URL="${RUNNER_REGISTER_URL:-http://$RUNNER_IP_ADDRESS:$GITEA_PORT}"
|
||||
#
|
||||
echo "Initializing $RUNNER_NAME in $RUNNER_HOME"
|
||||
#
|
||||
[ -d "$RUNNER_HOME" ] || mkdir -p "$RUNNER_HOME"
|
||||
[ -d "$TMP_DIR/runners/$RUNNER_NAME" ] || mkdir -p "$TMP_DIR/runners/$RUNNER_NAME"
|
||||
#
|
||||
[ -f "$CONF_DIR/tokens/system" ] && { grep -qs '.' "$CONF_DIR/tokens/system" || rm -Rf "$CONF_DIR/tokens/system"; }
|
||||
[ -f "$CONF_DIR/tokens/$RUNNER_NAME" ] && { grep -qs '.' "$CONF_DIR/tokens/$RUNNER_NAME" || rm -Rf "$CONF_DIR/tokens/$RUNNER_NAME"; }
|
||||
#
|
||||
[ -z "$RUNNER_NAME" ] && [ -z "$RUNNER_HOME" ] && echo "RUNNER_NAME or RUNNER_HOME is not set" >&2 && break
|
||||
#
|
||||
[ -s "$CONF_DIR/tokens/system" ] && RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$(<"$CONF_DIR/tokens/system")}"
|
||||
[ -s "$CONF_DIR/tokens/$RUNNER_NAME" ] && RUNNER_AUTH_TOKEN="${RUNNER_AUTH_TOKEN:-$(<"$CONF_DIR/tokens/$RUNNER_NAME")}"
|
||||
#
|
||||
printf '%s' "$RUNNER_AUTH_TOKEN" >"$CONF_DIR/tokens/$RUNNER_NAME"
|
||||
chmod -Rf 600 "$CONF_DIR/tokens/system" "$CONF_DIR/tokens/$RUNNER_NAME" 2>/dev/null
|
||||
#
|
||||
if [ -z "$RUNNER_AUTH_TOKEN" ]; then
|
||||
echo "$(date +'%H:%M') Error: RUNNER_AUTH_TOKEN is not set - visit $INSTANCE_HOSTNAME/admin/actions/runners" >&2
|
||||
echo "Then edit $runner or set in $CONF_DIR/tokens/$RUNNER_NAME" >&2
|
||||
sleep 120
|
||||
else
|
||||
echo "creating $RUNNER_NAME in $RUNNER_HOME and registering with $RUNNER_HOSTNAME"
|
||||
[ -f "$RUNNER_HOME/$RUNNER_CONFIG_NAME" ] || copy "$RUNNER_CONFIG_DEFAULT" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_HOME" "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_TEMP" "$TMP_DIR/runners/$RUNNER_NAME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_CACHE_HOST" "$RUNNER_CACHE_HOST" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
|
||||
__replace "REPLACE_RUNNER_CACHE_PORT" "$RUNNER_CACHE_PORT" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"
|
||||
if grep -sq "$RUNNER_HOME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME" && grep -sq "$TMP_DIR/runners/$RUNNER_NAME" "$RUNNER_HOME/$RUNNER_CONFIG_NAME"; then
|
||||
if [ -f "$RUNNER_HOME/runners" ]; then
|
||||
echo "Runner exists in: $RUNNER_HOME/runners" >&2
|
||||
break
|
||||
else
|
||||
(act_runner register --config "$RUNNER_HOME/$RUNNER_CONFIG_NAME" --labels "$RUNNER_LABELS" --name "$RUNNER_NAME" --instance "$RUNNER_REGISTER_URL" --token "$RUNNER_AUTH_TOKEN" --no-interactive 2>/dev/stdout >>"$RUNNER_LOG_FILE" && sleep 10) &
|
||||
pid=$(__pid_exists $!)
|
||||
sleep 4
|
||||
if [ -n "$pid" ] || [ -f "$RUNNER_HOME/runners" ]; then
|
||||
copy "$runner" "$RUNNER_HOME/$RUNNER_NAME.reg"
|
||||
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$RUNNER_HOME"
|
||||
echo "$RUNNER_NAME has been registered"
|
||||
exitStatus=0
|
||||
break
|
||||
else
|
||||
exitStatus=$((exitStatus++))
|
||||
echo "$(date +'%H:%M') Failed to register $RUNNER_NAME - $exitStatus" >&2
|
||||
sleep 20
|
||||
fi
|
||||
fi
|
||||
else
|
||||
exitStatus=$((exitStatus++))
|
||||
echo "Something seems to have gone wrong modifying $RUNNER_HOME/$RUNNER_CONFIG_NAME" >&2
|
||||
break
|
||||
fi
|
||||
fi
|
||||
echo "$RUNNER_NAME seems to be configured"
|
||||
unset RUNNER_HOME RUNNER_NAME RUNNER_AUTH_TOKEN RUNNER_HOSTNAME RUNNER_REGISTER_URL
|
||||
done
|
||||
fi
|
||||
echo "Done proccessing $runner"
|
||||
done 2>"/dev/stderr" | tee -p -a "$LOG_DIR/init.txt" >/dev/null
|
||||
fi
|
||||
exitStatus="${exitStatus:-0}"
|
||||
chown -Rf "$SERVICE_USER":"$SERVICE_GROUP" "$CONF_DIR" "$ETC_DIR" "$DATA_DIR" 2>/dev/null
|
||||
@ -457,10 +362,10 @@ __post_execute() {
|
||||
__banner "$postMessageST"
|
||||
# commands to execute
|
||||
if [ -f "$RUNNER_DEFAULT_HOME/runners" ] && [ -f "$RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME" ]; then
|
||||
act_runner daemon --config $RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME >>"$RUNNER_DAEMON_LOG" &
|
||||
act_runner daemon --config $RUNNER_DEFAULT_HOME/$RUNNER_CONFIG_NAME >>"$RUNNER_DAEMON_LOG" 2>/dev/stderr &
|
||||
pid=$!
|
||||
sleep 5 && ps ax | awk '{print $1}' | grep -v 'grep' | grep -q "$pid$" && is_running="yes"
|
||||
if [ "$is_running" = "yes" ]; then
|
||||
sleep 5
|
||||
if ps ax | awk '{print $1}' | grep -v 'grep' | grep -q "$pid$"; then
|
||||
echo "$(date)" >"$CONF_DIR/.runner"
|
||||
echo "$pid" >"$RUN_DIR/act_runner.gitea.pid"
|
||||
echo "Runner: gitea has been started with pid: $pid" | tee -a -p "$LOG_DIR/init.txt"
|
||||
@ -468,40 +373,22 @@ __post_execute() {
|
||||
echo "Runner: gitea has failed to start" >/dev/stderr
|
||||
[ -f "$RUN_DIR/act_runner.gitea.pid" ] && rm -f "$RUN_DIR/act_runner.gitea.pid"
|
||||
fi
|
||||
unset pid is_running
|
||||
unset pid
|
||||
fi
|
||||
#
|
||||
if [ -d "$RUNNER_MULTI_DIR" ]; then
|
||||
for multi_dir in "$RUNNER_MULTI_DIR"/*; do
|
||||
if [ -n "$multi_dir" ] && [ -d "$multi_dir" ]; then
|
||||
name="$(basename "$multi_dir")"
|
||||
conf="$multi_dir/$RUNNER_CONFIG_NAME"
|
||||
if [ -f "$conf" ] && [ -f "$multi_dir/runners" ]; then
|
||||
act_runner daemon --config $conf >>"$RUNNER_DAEMON_LOG" &
|
||||
pid=$!
|
||||
sleep 5 && ps ax | awk '{print $1}' | grep -v 'grep' | grep -q "$pid$" && is_running="yes"
|
||||
if [ "$is_running" = "yes" ]; then
|
||||
echo "$pid" >"$RUN_DIR/act_runner.$name.pid"
|
||||
echo "Runner: $name has been started with pid: $pid" | tee -a -p "$LOG_DIR/init.txt"
|
||||
else
|
||||
echo "Runner: $name has failed to start" >/dev/stderr
|
||||
[ -f "$RUN_DIR/act_runner.$name.pid" ] && rm -f "$RUN_DIR/act_runner.$name.pid"
|
||||
fi
|
||||
fi
|
||||
fi
|
||||
unset pid is_running name
|
||||
done
|
||||
fi
|
||||
if [ -f "$CACHE_CONFIG_FILE" ]; then
|
||||
mkdir -p "$DATA_DIR/cache"
|
||||
__replace "REPLACE_RUNNER_CACHE_DIR" "$DATA_DIR/cache" "$CACHE_CONFIG_FILE"
|
||||
__replace "REPLACE_RUNNER_CACHE_PORT" "$RUNNER_CACHE_PORT" "$CACHE_CONFIG_FILE"
|
||||
act_runner cache-server --config $CACHE_CONFIG_FILE -s 0.0.0.0 -p $RUNNER_CACHE_PORT 2>>/dev/stderr | tee -a -p "$CACHE_LOG_FILE" &
|
||||
act_runner cache-server --config $CACHE_CONFIG_FILE 2>>/dev/stderr >>"$CACHE_LOG_FILE" &
|
||||
execPid=$!
|
||||
if sleep 5 && ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$"; then
|
||||
sleep 5
|
||||
if ps ax | awk '{print $1}' | grep -v grep | grep -q "$execPid$"; then
|
||||
echo "Cache server has been started and is listening on $RUNNER_CACHE_PORT"
|
||||
else
|
||||
echo "Failed to start the cache server" >&2
|
||||
fi
|
||||
unset pid
|
||||
fi
|
||||
# show exit message
|
||||
__banner "$postMessageEnd: Status $retVal"
|
||||
|
Loading…
Reference in New Issue
Block a user