mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-08-01 17:38:36 +00:00
fix: forgejo-runner-service.sh misses LXC config & cache setting (#455)
Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/455 Reviewed-by: Michael Kriese <michael.kriese@gmx.de>
This commit is contained in:
commit
adad88969c
2 changed files with 28 additions and 8 deletions
|
@ -82,6 +82,10 @@ jobs:
|
||||||
service=/etc/systemd/system/forgejo-runner@.service
|
service=/etc/systemd/system/forgejo-runner@.service
|
||||||
cat $service
|
cat $service
|
||||||
|
|
||||||
|
cache=/var/lib/forgejo-runner/runner-$INPUTS_SERIAL-lxc/.cache/actcache
|
||||||
|
touch $cache/something
|
||||||
|
lxc-attach runner-$INPUTS_SERIAL-lxc -- test -f $cache/something
|
||||||
|
|
||||||
- name: forgejo-runner-service.sh start / stop
|
- name: forgejo-runner-service.sh start / stop
|
||||||
run: |
|
run: |
|
||||||
set -x
|
set -x
|
||||||
|
|
|
@ -31,6 +31,7 @@ SELF_FILENAME=$(basename "$SELF")
|
||||||
ETC=/etc/forgejo-runner
|
ETC=/etc/forgejo-runner
|
||||||
LIB=/var/lib/forgejo-runner
|
LIB=/var/lib/forgejo-runner
|
||||||
LOG=/var/log/forgejo-runner
|
LOG=/var/log/forgejo-runner
|
||||||
|
LOCK=/var/lock/forgejo-runner
|
||||||
: ${HOST:=$(hostname)}
|
: ${HOST:=$(hostname)}
|
||||||
|
|
||||||
LXC_IPV4_PREFIX="10.105.7"
|
LXC_IPV4_PREFIX="10.105.7"
|
||||||
|
@ -159,13 +160,14 @@ function inside() {
|
||||||
local name=$(lxc_name)
|
local name=$(lxc_name)
|
||||||
|
|
||||||
lxc-helpers.sh lxc_container_run $name -- sudo --user $LXC_USER_NAME \
|
lxc-helpers.sh lxc_container_run $name -- sudo --user $LXC_USER_NAME \
|
||||||
INPUTS_SERIAL=$INPUTS_SERIAL \
|
INPUTS_SERIAL="$INPUTS_SERIAL" \
|
||||||
INPUTS_TOKEN=$INPUTS_TOKEN \
|
INPUTS_LXC_CONFIG="$INPUTS_LXC_CONFIG" \
|
||||||
INPUTS_FORGEJO=$INPUTS_FORGEJO \
|
INPUTS_TOKEN="$INPUTS_TOKEN" \
|
||||||
INPUTS_LIFETIME=$INPUTS_LIFETIME \
|
INPUTS_FORGEJO="$INPUTS_FORGEJO" \
|
||||||
KILL_AFTER=$KILL_AFTER \
|
INPUTS_LIFETIME="$INPUTS_LIFETIME" \
|
||||||
VERBOSE=$VERBOSE \
|
KILL_AFTER="$KILL_AFTER" \
|
||||||
HOST=$HOST \
|
VERBOSE="$VERBOSE" \
|
||||||
|
HOST="$HOST" \
|
||||||
$SELF_FILENAME "$@"
|
$SELF_FILENAME "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -206,6 +208,11 @@ function ensure_configuration_and_registration() {
|
||||||
.runner.labels = ["docker:docker://data.forgejo.org/oci/node:${NODEJS_VERSION}-${DEBIAN_RELEASE}","lxc:lxc://debian:${DEBIAN_RELEASE}"]
|
.runner.labels = ["docker:docker://data.forgejo.org/oci/node:${NODEJS_VERSION}-${DEBIAN_RELEASE}","lxc:lxc://debian:${DEBIAN_RELEASE}"]
|
||||||
EOF
|
EOF
|
||||||
yq --inplace --from-file $TMPDIR/edit-config $etc/config.yml
|
yq --inplace --from-file $TMPDIR/edit-config $etc/config.yml
|
||||||
|
cat >$TMPDIR/edit-config <<EOF
|
||||||
|
.cache.dir = "/var/lib/forgejo-runner/runner-${INPUTS_SERIAL}-lxc/.cache/actcache"
|
||||||
|
EOF
|
||||||
|
yq --inplace --from-file $TMPDIR/edit-config $etc/config.yml
|
||||||
|
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if ! test -f $etc/env; then
|
if ! test -f $etc/env; then
|
||||||
|
@ -247,10 +254,19 @@ function daemon() {
|
||||||
set -e
|
set -e
|
||||||
}
|
}
|
||||||
|
|
||||||
function start() {
|
function destroy_and_create() {
|
||||||
stop
|
stop
|
||||||
lxc-helpers.sh lxc_container_destroy $(lxc_name)
|
lxc-helpers.sh lxc_container_destroy $(lxc_name)
|
||||||
lxc_create
|
lxc_create
|
||||||
|
}
|
||||||
|
|
||||||
|
function start() {
|
||||||
|
# it should be more than
|
||||||
|
# (time it takes for one runner to be recreated) * (number of runners)
|
||||||
|
# because they will all start at the same time on boot
|
||||||
|
local timeout=3600
|
||||||
|
|
||||||
|
flock --timeout $timeout $LOCK $SELF destroy_and_create
|
||||||
|
|
||||||
local log=$LOG/$INPUTS_SERIAL.log
|
local log=$LOG/$INPUTS_SERIAL.log
|
||||||
if test -f $log; then
|
if test -f $log; then
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue