mirror of
https://code.forgejo.org/forgejo/runner.git
synced 2025-06-27 16:35:58 +00:00
fix: lxc-systemd: upgrade using a URL instead of a version [skip cascade] (#520)
It is common to install a version from a branch or a fork. Change the upgrade to be a URL instead of a version number for simplicity. Fix a bug by which the lxc-helpers and the runner are upgraded but not the script itself. Increase the service unit timeout when stopping the runner: it may take up to three hours. Adapt the tests accordingly. Fixes https://code.forgejo.org/forgejo/runner/issues/510 Reviewed-on: https://code.forgejo.org/forgejo/runner/pulls/520 Reviewed-by: Michael Kriese <michael.kriese@gmx.de> Co-authored-by: Earl Warren <contact@earl-warren.org> Co-committed-by: Earl Warren <contact@earl-warren.org>
This commit is contained in:
parent
fcdd2ea974
commit
f8c98d141c
3 changed files with 31 additions and 24 deletions
|
@ -43,7 +43,7 @@ jobs:
|
||||||
done
|
done
|
||||||
|
|
||||||
cd examples/lxc-systemd
|
cd examples/lxc-systemd
|
||||||
VERBOSE=true ./forgejo-runner-service.sh upgrade 1.2.3 $(pwd)/forgejo-runner-service.sh
|
VERBOSE=true ./forgejo-runner-service.sh upgrade file://$(pwd)/forgejo-runner-service.sh
|
||||||
|
|
||||||
for script in $scripts; do
|
for script in $scripts; do
|
||||||
! grep --quiet something $bin/$script
|
! grep --quiet something $bin/$script
|
||||||
|
|
|
@ -23,20 +23,13 @@ forgejo-runner-service.sh installs a [Forgejo runner](https://forgejo.org/docs/n
|
||||||
|
|
||||||
The following will be upgraded:
|
The following will be upgraded:
|
||||||
|
|
||||||
- `forgejo-runner-service.sh` will replace itself with the version found at `https://code.forgejo.org/forgejo/runner/src/tag/vX.Y.Z/examples/lxc-systemd/forgejo-runner-service.sh`
|
- `forgejo-runner-service.sh` will replace itself with the script found at the provided URL (e.g. `https://code.forgejo.org/forgejo/runner/src/tag/v6.3.1/examples/lxc-systemd/forgejo-runner-service.sh`)
|
||||||
- `lxc-helpers*.sh` will be replaced with the version pinned in `forgejo-runner-service.sh`
|
- `lxc-helpers*.sh` will be replaced with the version pinned in `forgejo-runner-service.sh`
|
||||||
|
- `forgejo-runner-X.Y.Z` will default to the version hardcoded in `forgejo-runner-service.sh`
|
||||||
|
|
||||||
Upgrade to the version X.Y.Z (e.g 6.2.1):
|
Example:
|
||||||
|
|
||||||
- `forgejo-runner-service.sh upgrade X.Y.Z`
|
- `forgejo-runner-service.sh upgrade https://code.forgejo.org/forgejo/runner/src/tag/v6.3.1/examples/lxc-systemd/forgejo-runner-service.sh`
|
||||||
|
|
||||||
### Using a specific version of the Forgejo runner
|
|
||||||
|
|
||||||
The goal is that a LXC container uses a version of the Forgejo runner
|
|
||||||
that is different from the default. It needs to be installed and pinned.
|
|
||||||
|
|
||||||
- Install: `INPUTS_RUNNER_VERSION=6.3.0 forgejo-runner-service.sh install_runner`
|
|
||||||
- Pin the version in `/etc/forgejo-runner/N/env` (e.g. `INPUTS_RUNNER_VERSION=6.3.0`)
|
|
||||||
|
|
||||||
## Description
|
## Description
|
||||||
|
|
||||||
|
@ -87,3 +80,11 @@ The creation of a new runner is driven by the following environment variables:
|
||||||
systemctl status forgejo-runner@$serial
|
systemctl status forgejo-runner@$serial
|
||||||
```
|
```
|
||||||
- Set debug by adding `VERBOSE=true` in `/etc/forgejo-runner/$INPUTS_SERIAL/env`
|
- Set debug by adding `VERBOSE=true` in `/etc/forgejo-runner/$INPUTS_SERIAL/env`
|
||||||
|
|
||||||
|
### Use a specific version of the Forgejo runner
|
||||||
|
|
||||||
|
The goal is that a LXC container uses a version of the Forgejo runner
|
||||||
|
that is different from the default. It needs to be installed and pinned.
|
||||||
|
|
||||||
|
- Install: `INPUTS_RUNNER_VERSION=6.3.0 forgejo-runner-service.sh install_runner`
|
||||||
|
- Pin the version in `/etc/forgejo-runner/N/env` (e.g. `INPUTS_RUNNER_VERSION=6.3.0`)
|
||||||
|
|
|
@ -21,7 +21,7 @@ trap "rm -fr $TMPDIR" EXIT
|
||||||
: ${INPUTS_FORGEJO:=https://code.forgejo.org}
|
: ${INPUTS_FORGEJO:=https://code.forgejo.org}
|
||||||
: ${INPUTS_LIFETIME:=7d}
|
: ${INPUTS_LIFETIME:=7d}
|
||||||
: ${INPUTS_LXC_HELPERS_VERSION:=1.0.3}
|
: ${INPUTS_LXC_HELPERS_VERSION:=1.0.3}
|
||||||
: ${INPUTS_RUNNER_VERSION:=6.3.0}
|
: ${INPUTS_RUNNER_VERSION:=6.3.1}
|
||||||
|
|
||||||
: ${KILL_AFTER:=21600} # 6h == 21600
|
: ${KILL_AFTER:=21600} # 6h == 21600
|
||||||
NODEJS_VERSION=20
|
NODEJS_VERSION=20
|
||||||
|
@ -29,6 +29,7 @@ DEBIAN_RELEASE=bookworm
|
||||||
YQ_VERSION=v4.45.1
|
YQ_VERSION=v4.45.1
|
||||||
SELF=${BASH_SOURCE[0]}
|
SELF=${BASH_SOURCE[0]}
|
||||||
SELF_FILENAME=$(basename "$SELF")
|
SELF_FILENAME=$(basename "$SELF")
|
||||||
|
SELF_INSTALLED=/usr/local/bin/$SELF_FILENAME
|
||||||
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
|
||||||
|
@ -76,13 +77,11 @@ function install_or_update_lxc_helpers() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function install_or_update_self() {
|
function install_or_update_self() {
|
||||||
local bin=/usr/local/bin/$SELF_FILENAME
|
if ! cmp --quiet $SELF $SELF_INSTALLED; then
|
||||||
|
if test -f $SELF_INSTALLED; then
|
||||||
if ! cmp --quiet $SELF $bin; then
|
$SUDO mv $SELF_INSTALLED $SELF_INSTALLED.backup
|
||||||
if test -f $bin; then
|
|
||||||
$SUDO mv $bin $bin.backup
|
|
||||||
fi
|
fi
|
||||||
$SUDO cp -a $SELF $bin
|
$SUDO cp -a $SELF $SELF_INSTALLED
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -160,6 +159,7 @@ After=network.target
|
||||||
Restart=on-success
|
Restart=on-success
|
||||||
ExecStart=/usr/local/bin/${SELF_FILENAME} run_in_copy start
|
ExecStart=/usr/local/bin/${SELF_FILENAME} run_in_copy start
|
||||||
ExecStop=/usr/local/bin/${SELF_FILENAME} stop
|
ExecStop=/usr/local/bin/${SELF_FILENAME} stop
|
||||||
|
TimeoutStopSec=10800
|
||||||
EnvironmentFile=/etc/forgejo-runner/%i/env
|
EnvironmentFile=/etc/forgejo-runner/%i/env
|
||||||
|
|
||||||
[Install]
|
[Install]
|
||||||
|
@ -197,6 +197,10 @@ function inside() {
|
||||||
$SELF_FILENAME "$@"
|
$SELF_FILENAME "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function display_default_runner_version() {
|
||||||
|
echo "Forgejo runner $INPUTS_RUNNER_VERSION"
|
||||||
|
}
|
||||||
|
|
||||||
function install_runner() {
|
function install_runner() {
|
||||||
local runner=/usr/local/bin/forgejo-runner-$INPUTS_RUNNER_VERSION
|
local runner=/usr/local/bin/forgejo-runner-$INPUTS_RUNNER_VERSION
|
||||||
if test -f $runner; then
|
if test -f $runner; then
|
||||||
|
@ -355,14 +359,16 @@ function upgrade() {
|
||||||
}
|
}
|
||||||
|
|
||||||
function upgrade_safely() {
|
function upgrade_safely() {
|
||||||
local version="${1:-$INPUTS_RUNNER_VERSION}"
|
local url="$1"
|
||||||
local upgrade="${2:-$TMPDIR/$SELF_FILENAME}"
|
|
||||||
|
|
||||||
if ! test -f $upgrade; then
|
local upgrade_dir=$TMPDIR/upgrades
|
||||||
curl --fail -sS -o $upgrade https://code.forgejo.org/forgejo/runner/raw/tag/v$version/examples/lxc-systemd/forgejo-runner-service.sh
|
mkdir -p $TMPDIR/upgrades
|
||||||
fi
|
local upgrade="$upgrade_dir/$SELF_FILENAME"
|
||||||
|
|
||||||
|
curl --fail -sS -o $upgrade $url
|
||||||
chmod +x $upgrade
|
chmod +x $upgrade
|
||||||
$upgrade install_runner
|
$upgrade install_runner
|
||||||
|
$upgrade display_default_runner_version
|
||||||
$upgrade install_or_update_lxc_helpers
|
$upgrade install_or_update_lxc_helpers
|
||||||
$upgrade install_or_update_self
|
$upgrade install_or_update_self
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue