Skip to content

The Unified and Autonomous Development Platform

chore: Refresh wrapper runtime and simplify updates

Robin Shen26727519b3fd
diff --git a/server-product/wrapper/README.md b/server-product/wrapper/README.md
index 0817b9b0f8..fcbb550ee8 100644
--- a/server-product/wrapper/README.md
+++ b/server-product/wrapper/README.md
@@ -26,6 +26,9 @@ them using the same verification and adaptation described below. The site contai
the latest successful publication. Downloads are removed after the update.
Review and commit the updated files in this directory with the server changes.
+Every remote or local update imports the files and regenerates the prepared
+server and agent configurations, even when the version is unchanged.
+
For local testing, build in the sibling wrapper checkout and import its
output directly, without creating or downloading a release archive:
@@ -51,7 +54,7 @@ server-product\wrapper\update.bat import C:\downloads\wrapper-VERSION.tar.gz
Pass `/path/to/wrapper` for a checkout elsewhere. This copies the
available binaries and `wrapper.jar` from `dist/boot`, adapts the checkout's
-launcher templates, and refreshes both server and agent files and checksums.
+launcher templates, and refreshes both server and agent files.
Platforms absent from the local build retain their bundled binaries, so a
host-only `./build.sh` is sufficient. All binaries already in `dist/boot` are
imported, including those from previous builds. `VERSION` is marked with a
@@ -86,11 +89,11 @@ and its `.sha256` together, then run:
./server-product/wrapper/update.sh import /path/to/wrapper-VERSION.tar.gz
```
-The importer verifies the archive and file checksums, copies all upstream boot
-files and adapts generic launchers for server/agent and one-shot utilities.
-It renders server and agent configurations from
-`wrapper.conf` and regenerates `SHA256SUMS`. These integration rules live in the
-server project. The agent configuration retains the `agentVersion` placeholder,
+The importer verifies the archive's `.sha256` checksum. It accepts both
+`wrapper-latest.tar.gz` and versioned archives, copies all upstream boot files,
+and adapts generic launchers for server/agent and one-shot utilities. It renders
+server and agent configurations from `wrapper.conf`. These integration rules
+live in the server project. The agent configuration retains the `agentVersion` placeholder,
which is resolved when assembling a standalone agent or downloading one.
`distribution/` contains the exact installation-relative files Maven will copy:
diff --git a/server-product/wrapper/SHA256SUMS b/server-product/wrapper/SHA256SUMS
deleted file mode 100644
index def9397d41..0000000000
--- a/server-product/wrapper/SHA256SUMS
+++ /dev/null
@@ -1,35 +0,0 @@
-6f2ba3a6933bf3b8537c3345138a15f2a3a60bf23b5a73dc4c0b442a410eaf88 README.md
-0f8fee02328a33ee30e1ecf2b9029eb41ae72f34bbc1ae451ddb74a581190e06 VERSION
-09b9ab6e27f5c12730f6859e69e16894ed8c8b91e9b8b232b2416e071967755d distribution/agent/bin/agent.bat
-c7d559be45ff68e111b996d720abdd427d57c8de1228a3705fd6fc37df3fe72b distribution/agent/bin/agent.sh
-1102c500067c908f941a6a105c9563a89a760664cbfdc2519befa8645b5c381c distribution/agent/boot/wrapper-linux-arm-64
-ac78e3982c0558116a5f3d112a315af63695ebc21562c542c30a08a54d7d6e0a distribution/agent/boot/wrapper-linux-x86-64
-ec378dbd20a8da8cda8cf117439f9745052bd65138ab8dad1a060405d94c13b4 distribution/agent/boot/wrapper-macosx-arm-64
-bb04575c2447d5ddf55ec557aa7b0abc1fc043ef78d907e240a4e7865ff624e9 distribution/agent/boot/wrapper-windows-arm-64.exe
-a05a47d0e654feebd9f26aaee8518903906822a98af4c98d490c9399a1cdb7da distribution/agent/boot/wrapper-windows-x86-64.exe
-23818027719188f4184b198312e890e78b123ab1222cebf79a59013174f9ebaf distribution/agent/boot/wrapper.jar
-770ac892058e45eb81b1993a597899aae85dc4963d8c97c63f21e7e0b11e3275 distribution/agent/conf/wrapper.conf
-cc39e461649677e33cff7ca01e10580a227f2e68a8d93b866a13724c19e0abed distribution/bin/apply-db-constraints.bat
-e6d3c772c3c77ddfc1e0f2bd8eadd7df098b8885b21fcd94b4d4101a2be24a08 distribution/bin/apply-db-constraints.sh
-cc39e461649677e33cff7ca01e10580a227f2e68a8d93b866a13724c19e0abed distribution/bin/backup-db.bat
-e6d3c772c3c77ddfc1e0f2bd8eadd7df098b8885b21fcd94b4d4101a2be24a08 distribution/bin/backup-db.sh
-cc39e461649677e33cff7ca01e10580a227f2e68a8d93b866a13724c19e0abed distribution/bin/enable-internal-login.bat
-e6d3c772c3c77ddfc1e0f2bd8eadd7df098b8885b21fcd94b4d4101a2be24a08 distribution/bin/enable-internal-login.sh
-cc39e461649677e33cff7ca01e10580a227f2e68a8d93b866a13724c19e0abed distribution/bin/reset-admin-password.bat
-e6d3c772c3c77ddfc1e0f2bd8eadd7df098b8885b21fcd94b4d4101a2be24a08 distribution/bin/reset-admin-password.sh
-cc39e461649677e33cff7ca01e10580a227f2e68a8d93b866a13724c19e0abed distribution/bin/restore-db.bat
-e6d3c772c3c77ddfc1e0f2bd8eadd7df098b8885b21fcd94b4d4101a2be24a08 distribution/bin/restore-db.sh
-09b9ab6e27f5c12730f6859e69e16894ed8c8b91e9b8b232b2416e071967755d distribution/bin/server.bat
-c7d559be45ff68e111b996d720abdd427d57c8de1228a3705fd6fc37df3fe72b distribution/bin/server.sh
-cc39e461649677e33cff7ca01e10580a227f2e68a8d93b866a13724c19e0abed distribution/bin/upgrade.bat
-e6d3c772c3c77ddfc1e0f2bd8eadd7df098b8885b21fcd94b4d4101a2be24a08 distribution/bin/upgrade.sh
-1102c500067c908f941a6a105c9563a89a760664cbfdc2519befa8645b5c381c distribution/boot/wrapper-linux-arm-64
-ac78e3982c0558116a5f3d112a315af63695ebc21562c542c30a08a54d7d6e0a distribution/boot/wrapper-linux-x86-64
-ec378dbd20a8da8cda8cf117439f9745052bd65138ab8dad1a060405d94c13b4 distribution/boot/wrapper-macosx-arm-64
-bb04575c2447d5ddf55ec557aa7b0abc1fc043ef78d907e240a4e7865ff624e9 distribution/boot/wrapper-windows-arm-64.exe
-a05a47d0e654feebd9f26aaee8518903906822a98af4c98d490c9399a1cdb7da distribution/boot/wrapper-windows-x86-64.exe
-23818027719188f4184b198312e890e78b123ab1222cebf79a59013174f9ebaf distribution/boot/wrapper.jar
-11095b3b72a3a68b222e4df43921f2272fd402c90f031bd3eed131d3b7a2cb90 distribution/conf/wrapper.conf
-3d27d272d40c15f2095c0d88a3ef9165c4256af60e4f6a80ebbfa78e8a5d6797 update.bat
-94f3649ff97b62914bef3ac7ece618d7368de8bf7253c2131d0add9895b19104 update.sh
-c34604bff6d87100c5c1c5f0afcdf96f6d99184fe9d09204d968461c52334a19 wrapper.conf
diff --git a/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64 b/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64
index 8b228c8a80..bea18161b5 100755
Binary files a/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64 and b/server-product/wrapper/distribution/agent/boot/wrapper-linux-arm-64 differ
diff --git a/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64 b/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64
index 59fa31187e..ca44639c0f 100755
Binary files a/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64 and b/server-product/wrapper/distribution/agent/boot/wrapper-linux-x86-64 differ
diff --git a/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64 b/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64
index fe3bea5e60..31a0ea2e43 100755
Binary files a/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64 and b/server-product/wrapper/distribution/agent/boot/wrapper-macosx-arm-64 differ
diff --git a/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exe b/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exe
index 2312263c3b..a8625847ad 100755
Binary files a/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exe and b/server-product/wrapper/distribution/agent/boot/wrapper-windows-arm-64.exe differ
diff --git a/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exe b/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exe
index fba7652838..8b9f42cee8 100755
Binary files a/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exe and b/server-product/wrapper/distribution/agent/boot/wrapper-windows-x86-64.exe differ
diff --git a/server-product/wrapper/distribution/agent/boot/wrapper.jar b/server-product/wrapper/distribution/agent/boot/wrapper.jar
index 676e0aa6b1..918ee203e3 100644
Binary files a/server-product/wrapper/distribution/agent/boot/wrapper.jar and b/server-product/wrapper/distribution/agent/boot/wrapper.jar differ
diff --git a/server-product/wrapper/distribution/agent/conf/wrapper.conf b/server-product/wrapper/distribution/agent/conf/wrapper.conf
index 1a81fcf878..4da749ea27 100644
--- a/server-product/wrapper/distribution/agent/conf/wrapper.conf
+++ b/server-product/wrapper/distribution/agent/conf/wrapper.conf
@@ -60,7 +60,5 @@ wrapper.ntservice.password=
# Zero allows unlimited startup/shutdown time. Java shutdown hooks run on stop.
wrapper.startup.timeout=0
wrapper.shutdown.timeout=0
-# Consecutive unexpected JVM failures are bounded to prevent a restart loop.
+# Delay before an application-requested restart. Unexpected JVM exits stop Wrapper.
wrapper.restart.delay=5
-wrapper.max_failed_invocations=5
-wrapper.successful_invocation_time=300
diff --git a/server-product/wrapper/distribution/boot/wrapper-linux-arm-64 b/server-product/wrapper/distribution/boot/wrapper-linux-arm-64
index 8b228c8a80..bea18161b5 100755
Binary files a/server-product/wrapper/distribution/boot/wrapper-linux-arm-64 and b/server-product/wrapper/distribution/boot/wrapper-linux-arm-64 differ
diff --git a/server-product/wrapper/distribution/boot/wrapper-linux-x86-64 b/server-product/wrapper/distribution/boot/wrapper-linux-x86-64
index 59fa31187e..ca44639c0f 100755
Binary files a/server-product/wrapper/distribution/boot/wrapper-linux-x86-64 and b/server-product/wrapper/distribution/boot/wrapper-linux-x86-64 differ
diff --git a/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64 b/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64
index fe3bea5e60..31a0ea2e43 100755
Binary files a/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64 and b/server-product/wrapper/distribution/boot/wrapper-macosx-arm-64 differ
diff --git a/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exe b/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exe
index 2312263c3b..a8625847ad 100755
Binary files a/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exe and b/server-product/wrapper/distribution/boot/wrapper-windows-arm-64.exe differ
diff --git a/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exe b/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exe
index fba7652838..8b9f42cee8 100755
Binary files a/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exe and b/server-product/wrapper/distribution/boot/wrapper-windows-x86-64.exe differ
diff --git a/server-product/wrapper/distribution/boot/wrapper.jar b/server-product/wrapper/distribution/boot/wrapper.jar
index 676e0aa6b1..918ee203e3 100644
Binary files a/server-product/wrapper/distribution/boot/wrapper.jar and b/server-product/wrapper/distribution/boot/wrapper.jar differ
diff --git a/server-product/wrapper/distribution/conf/wrapper.conf b/server-product/wrapper/distribution/conf/wrapper.conf
index 4ff3ed3cba..b9f05690a8 100644
--- a/server-product/wrapper/distribution/conf/wrapper.conf
+++ b/server-product/wrapper/distribution/conf/wrapper.conf
@@ -60,7 +60,5 @@ wrapper.ntservice.password=
# Zero allows unlimited startup/shutdown time. Java shutdown hooks run on stop.
wrapper.startup.timeout=0
wrapper.shutdown.timeout=0
-# Consecutive unexpected JVM failures are bounded to prevent a restart loop.
+# Delay before an application-requested restart. Unexpected JVM exits stop Wrapper.
wrapper.restart.delay=5
-wrapper.max_failed_invocations=5
-wrapper.successful_invocation_time=300
diff --git a/server-product/wrapper/update.bat b/server-product/wrapper/update.bat
index fecb924ac0..8d94479e44 100644
--- a/server-product/wrapper/update.bat
+++ b/server-product/wrapper/update.bat
@@ -111,32 +111,6 @@ function Get-FileList([string] $Directory) {
return $names
}
-function Write-Manifest([string] $Directory) {
- $lines = foreach ($name in Get-FileList $Directory) {
- if ($name -eq 'SHA256SUMS') { continue }
- Assert-ReleasePath $name
- (Get-Digest (Join-Path $Directory $name)) + ' ' + $name
- }
- Write-Text (Join-Path $Directory 'SHA256SUMS') (($lines -join "`n") + "`n")
-}
-
-function Test-Manifest([string] $Directory) {
- $seen = @{}
- foreach ($line in [IO.File]::ReadAllLines((Join-Path $Directory 'SHA256SUMS'))) {
- $entry = Read-Checksum $line
- if ($entry.Name -eq 'SHA256SUMS' -or $seen.ContainsKey($entry.Name)) { throw 'Duplicate or self-referencing manifest entry' }
- $seen[$entry.Name] = $true
- if ((Get-Digest (Join-Path $Directory $entry.Name)) -cne $entry.Digest) {
- throw "Release file checksum does not match: $($entry.Name)"
- }
- }
- $files = @(Get-FileList $Directory | Where-Object { $_ -ne 'SHA256SUMS' })
- if ($files.Count -ne $seen.Count) { throw 'Release manifest must cover every file exactly once' }
- foreach ($name in $files) {
- if (-not $seen.ContainsKey($name)) { throw "Unlisted release file: $name" }
- }
-}
-
function Invoke-Tar([string[]] $Arguments) {
& tar.exe @Arguments
if ($LASTEXITCODE -ne 0) { throw "tar.exe failed with exit code $LASTEXITCODE" }
@@ -204,9 +178,8 @@ function Prepare-Distribution([string] $Release, [string] $Destination, [bool] $
$temporary = New-TemporaryDirectory
try {
$prepared = Join-Path $temporary 'prepared'
- Copy-Contents $Destination $prepared
+ New-Directory $prepared
$distribution = Join-Path $prepared 'distribution'
- Remove-Tree $distribution $prepared
foreach ($name in @('bin', 'conf', 'agent/bin', 'agent/conf')) { New-Directory (Join-Path $distribution $name) }
Copy-Contents (Join-Path $Release 'boot') (Join-Path $distribution 'boot')
Copy-Contents (Join-Path $Release 'boot') (Join-Path $distribution 'agent/boot')
@@ -232,12 +205,14 @@ function Prepare-Distribution([string] $Release, [string] $Destination, [bool] $
Write-Text (Join-Path $distribution "${prefix}conf/wrapper.conf") $text
}
Copy-Item -LiteralPath (Join-Path $Release 'VERSION') -Destination (Join-Path $prepared 'VERSION') -Force
- Write-Manifest $prepared
- # Finish validation before replacing the previous prepared distribution.
+ # Finish validation before replacing the prepared distribution, even at the same version.
Remove-Tree (Join-Path $Destination 'distribution') $Destination
Copy-Contents $distribution (Join-Path $Destination 'distribution')
- foreach ($name in @('VERSION', 'SHA256SUMS')) {
- Copy-Item -LiteralPath (Join-Path $prepared $name) -Destination (Join-Path $Destination $name) -Force
+ Copy-Item -LiteralPath (Join-Path $prepared 'VERSION') -Destination (Join-Path $Destination 'VERSION') -Force
+ # Remove the obsolete per-file manifest left by earlier updater versions.
+ $manifest = Join-Path $Destination 'SHA256SUMS'
+ if (Test-Path -LiteralPath $manifest) {
+ Remove-Item -LiteralPath $manifest -Force
}
Write-Host "Imported Wrapper $([IO.File]::ReadAllText((Join-Path $Destination 'VERSION')).Trim()) into $Destination"
if ($Sandbox) { Update-Sandbox (Join-Path $Destination 'distribution') $sandboxPath }
@@ -277,7 +252,6 @@ function Import-Release([string] $Archive, [string] $Checksum, [string] $Destina
Invoke-Tar @('-xzf', $Archive, '-C', $extracted)
$release = Join-Path $extracted $root
Assert-NoLinks $release
- Test-Manifest $release
Prepare-Distribution $release $Destination $Sandbox
} finally { Remove-Tree $temporary ([IO.Path]::GetTempPath()) }
}
@@ -310,7 +284,7 @@ function Update-Local([string] $Source, [string] $Destination, [bool] $Sandbox)
}
function Get-ReleaseName([string] $Html) {
- $names = @([regex]::Matches($Html, '(?i)<a\s+[^>]*?\bhref\s*=\s*["''](wrapper-[0-9][A-Za-z0-9.+-]*\.tar\.gz)["'']') |
+ $names = @([regex]::Matches($Html, '(?i)<a\s+[^>]*?\bhref\s*=\s*["''](wrapper-(?:latest|[0-9][A-Za-z0-9.+-]*)\.tar\.gz)["'']') |
ForEach-Object { $_.Groups[1].Value } | Sort-Object -Unique)
if ($names.Count -ne 1) { throw 'Expected exactly one Wrapper release on the public download site' }
return $names[0]
@@ -395,24 +369,29 @@ function Test-Updater {
Write-Text (Join-Path $fixture 'VERSION') "1.0.0`n"
$archive = Join-Path $temporary 'wrapper-1.0.0.tar.gz'
function Pack-Fixture {
- Write-Manifest $fixture
Invoke-Tar @('-czf', $archive, '-C', (Split-Path -Parent $fixture), 'wrapper-1.0.0')
Write-Text "$archive.sha256" ((Get-Digest $archive) + " wrapper-1.0.0.tar.gz`n")
}
function Assert-Equal($Actual, $Expected, [string] $Message) {
if ($Actual -cne $Expected) { throw "Test failed: $Message" }
}
+ function Get-PreparedSnapshot {
+ $files = foreach ($name in Get-FileList $destination) {
+ $name + ':' + (Get-Digest (Join-Path $destination $name))
+ }
+ return $files -join "`n"
+ }
function Expect-Rejection([scriptblock] $Action) {
- $before = Get-Digest (Join-Path $destination 'SHA256SUMS')
+ $before = Get-PreparedSnapshot
$rejected = $false
try { & $Action } catch { $rejected = $true }
if (-not $rejected) { throw 'Test failed: invalid input accepted' }
- Assert-Equal (Get-Digest (Join-Path $destination 'SHA256SUMS')) $before 'invalid input changed manifest'
- Test-Manifest $destination
+ Assert-Equal (Get-PreparedSnapshot) $before 'invalid input changed prepared files'
}
+ Write-Text (Join-Path $destination 'SHA256SUMS') 'obsolete manifest'
Pack-Fixture
Invoke-Updater @('import', $archive, '--destination', $destination)
- Test-Manifest $destination
+ if (Test-Path -LiteralPath (Join-Path $destination 'SHA256SUMS')) { throw 'Test failed: per-file manifest was generated' }
foreach ($prefix in @('', 'agent/')) {
Assert-Equal (Get-Digest (Join-Path $destination "distribution/${prefix}boot/future-runtime.dat")) (Get-Digest (Join-Path $fixture 'boot/future-runtime.dat')) 'binary bytes'
}
@@ -428,7 +407,6 @@ function Test-Updater {
Pack-Fixture
Write-Text (Join-Path $fixture 'boot/wrapper.jar') 'tampered'
Invoke-Tar @('-czf', $archive, '-C', (Split-Path -Parent $fixture), 'wrapper-1.0.0')
- Write-Text "$archive.sha256" ((Get-Digest $archive) + " wrapper-1.0.0.tar.gz`n")
Expect-Rejection { Import-Release $archive '' $destination $false }
$launcher = [IO.File]::ReadAllText((Join-Path $fixture 'bin/service.sh'))
Write-Text (Join-Path $fixture 'bin/service.sh') 'unrecognized'
@@ -444,7 +422,16 @@ function Test-Updater {
New-Directory (Join-Path $sandbox 'conf')
Write-Text (Join-Path $sandbox 'conf/wrapper.conf') 'preserve configuration'
Import-Release $archive '' $destination $true
+ Write-Text (Join-Path $fixture 'boot/wrapper.jar') 'updated release jar'
+ $configuration = Join-Path $destination 'wrapper.conf'
+ Write-Text $configuration ([IO.File]::ReadAllText($configuration).Replace('wrapper.logfile.maxfiles=3', 'wrapper.logfile.maxfiles=7'))
+ Pack-Fixture
Import-Release $archive '' $destination $true
+ Assert-Equal ([IO.File]::ReadAllText((Join-Path $destination 'VERSION'))) "1.0.0`n" 'same release version'
+ foreach ($prefix in @('', 'agent/')) {
+ Assert-Equal ([IO.File]::ReadAllText((Join-Path $destination "distribution/${prefix}boot/wrapper.jar"))) 'updated release jar' 'same version import'
+ if (-not ([IO.File]::ReadAllText((Join-Path $destination "distribution/${prefix}conf/wrapper.conf"))).Contains('wrapper.logfile.maxfiles=7')) { throw 'Test failed: configuration was not regenerated' }
+ }
Assert-Equal ([IO.File]::ReadAllText((Join-Path $sandbox 'conf/wrapper.conf'))) 'preserve configuration' 'sandbox configuration'
Assert-Equal (Get-Digest (Join-Path $sandbox 'agent/boot/wrapper.jar')) (Get-Digest (Join-Path $fixture 'boot/wrapper.jar')) 'sandbox binaries'
$checkout = Join-Path $temporary 'local checkout'
@@ -456,10 +443,20 @@ function Test-Updater {
Copy-Item -LiteralPath (Join-Path $fixture 'bin/service.sh') -Destination (Join-Path $checkout 'resources/App.sh.in')
Copy-Item -LiteralPath (Join-Path $fixture 'bin/service.bat') -Destination (Join-Path $checkout 'resources/AppCommand.bat.in')
Update-Local $checkout $destination $true
- Test-Manifest $destination
+ if (Test-Path -LiteralPath (Join-Path $destination 'SHA256SUMS')) { throw 'Test failed: per-file manifest was generated' }
Assert-Equal ([IO.File]::ReadAllText((Join-Path $destination 'VERSION'))) "2.0.0-local`n" 'local version'
Assert-Equal ([IO.File]::ReadAllText((Join-Path $sandbox 'boot/wrapper.jar'))) 'local jar' 'local sandbox refresh'
Assert-Equal (Get-Digest (Join-Path $destination 'distribution/boot/wrapper-linux-arm-64')) (Get-Digest (Join-Path $fixture 'boot/wrapper-linux-arm-64')) 'unbuilt platform retention'
+ Write-Text (Join-Path $checkout 'dist/boot/wrapper.jar') 'updated local jar'
+ Write-Text (Join-Path $checkout 'dist/boot/wrapper-windows-x86-64.exe') 'updated local binary'
+ Write-Text $configuration ([IO.File]::ReadAllText($configuration).Replace('wrapper.restart.delay=5', 'wrapper.restart.delay=2'))
+ Update-Local $checkout $destination $true
+ Assert-Equal ([IO.File]::ReadAllText((Join-Path $destination 'VERSION'))) "2.0.0-local`n" 'same local version'
+ foreach ($prefix in @('', 'agent/')) {
+ Assert-Equal ([IO.File]::ReadAllText((Join-Path $destination "distribution/${prefix}boot/wrapper.jar"))) 'updated local jar' 'same version local update'
+ Assert-Equal ([IO.File]::ReadAllText((Join-Path $sandbox "${prefix}boot/wrapper-windows-x86-64.exe"))) 'updated local binary' 'same version sandbox refresh'
+ if (-not ([IO.File]::ReadAllText((Join-Path $destination "distribution/${prefix}conf/wrapper.conf"))).Contains('wrapper.restart.delay=2')) { throw 'Test failed: local configuration was not regenerated' }
+ }
Assert-Equal (Get-ReleaseName '<a href="wrapper-1.0.0.tar.gz">release</a><a HREF=''wrapper-1.0.0.tar.gz''>duplicate</a>') 'wrapper-1.0.0.tar.gz' 'release discovery'
Expect-Rejection { Get-ReleaseName '<a href="wrapper-1.0.0.tar.gz">one</a><a href="wrapper-2.0.0.tar.gz">two</a>' }
Expect-Rejection { Get-ReleaseName '<a href="../wrapper-1.0.0.tar.gz">invalid</a>' }
diff --git a/server-product/wrapper/update.sh b/server-product/wrapper/update.sh
index cf1bd1e2d5..3af37c50f3 100755
--- a/server-product/wrapper/update.sh
+++ b/server-product/wrapper/update.sh
@@ -62,32 +62,6 @@ file_list() {
(cd "$1" && find . -type f | sed 's|^./||' | sort)
}
-write_manifest() {
- local directory=$1 name digest
- while IFS= read -r name; do
- [ "$name" = SHA256SUMS ] && continue
- valid_path "$name" || fail "Invalid release path: $name"
- digest=$(sha256 "$directory/$name")
- printf '%s %s\n' "$digest" "$name"
- done < <(file_list "$directory")
-}
-
-verify_manifest() {
- local directory=$1 line
- local names=()
- [ -f "$directory/SHA256SUMS" ] || fail "Missing SHA256SUMS in $directory"
- while IFS= read -r line || [ -n "$line" ]; do
- parse_checksum "$line"
- [ -f "$directory/$checksum_name" ] || fail "Missing release file: $checksum_name"
- [ "$(sha256 "$directory/$checksum_name")" = "$checksum_digest" ] \
- || fail "Release file checksum does not match: $checksum_name"
- names+=("$checksum_name")
- done < "$directory/SHA256SUMS"
- cmp -s <(printf '%s\n' "${names[@]}" | sort) \
- <(file_list "$directory" | sed '/^SHA256SUMS$/d') \
- || fail "Release manifest must cover every file exactly once"
-}
-
# Verify and adapt a release before replacing the prepared distribution.
import_release() (
import_usage() {
@@ -139,7 +113,6 @@ import_release() (
mkdir "$temporary/extracted"
tar -xzf "$archive" -C "$temporary/extracted"
release="$temporary/extracted/$root"
- verify_manifest "$release"
prepare_distribution "$release" "$destination" "$sandbox"
)
@@ -162,12 +135,10 @@ prepare_distribution() (
done
[ -f "$release/VERSION" ] || fail "Missing release VERSION"
- # Prepare all adaptations and checksums before replacing any checked-in files.
+ # Prepare all adaptations before replacing any checked-in files, even at the same version.
prepared="$temporary/prepared"
mkdir "$prepared"
- cp -R "$destination/." "$prepared/"
distribution="$prepared/distribution"
- rm -rf "$distribution"
mkdir -p "$distribution/bin" "$distribution/conf" "$distribution/agent/bin" "$distribution/agent/conf"
cp -R "$release/boot" "$distribution/boot"
cp -R "$distribution/boot" "$distribution/agent/boot"
@@ -204,10 +175,11 @@ prepare_distribution() (
esac
done < <(file_list "$distribution")
cp "$release/VERSION" "$prepared/VERSION"
- write_manifest "$prepared" > "$prepared/SHA256SUMS"
rm -rf "$destination/distribution"
mv "$distribution" "$destination/distribution"
- cp "$prepared/VERSION" "$prepared/SHA256SUMS" "$destination/"
+ cp "$prepared/VERSION" "$destination/"
+ # Remove the obsolete per-file manifest left by earlier updater versions.
+ rm -f "$destination/SHA256SUMS"
echo "Imported Wrapper $(cat "$destination/VERSION") into $destination"
if [ -n "$sandbox" ]; then
refresh_sandbox "$destination/distribution" "$sandbox"
@@ -302,7 +274,7 @@ update_release() (
# Each publication replaces the site with one release and its checksum.
awk 'BEGIN {RS="<"}
tolower($0) ~ /^a[[:space:]]/ {
- if (match($0, /[Hh][Rr][Ee][Ff][[:space:]]*=[[:space:]]*["\047]wrapper-[0-9][A-Za-z0-9.+-]*\.tar\.gz["\047]/)) {
+ if (match($0, /[Hh][Rr][Ee][Ff][[:space:]]*=[[:space:]]*["\047]wrapper-(latest|[0-9][A-Za-z0-9.+-]*)\.tar\.gz["\047]/)) {
name = substr($0, RSTART, RLENGTH)
sub(/^[^=]*=[[:space:]]*["\047]/, "", name)
sub(/["\047]$/, "", name)
@@ -382,8 +354,7 @@ check_package() (
fi
grep -qx sandbox/release.properties "$temporary/product-entries" || fail "Missing sandbox/release.properties"
done
- verify_manifest "$inputs"
- echo "Server archive, agent distribution, embedded product jar, permissions, and checksums verified"
+ echo "Server archive, agent distribution, embedded product jar, and permissions verified"
)
# Exercise the maintenance commands without native builds or network access.
@@ -405,7 +376,6 @@ test_wrapper() (
printf '1.0.0\n' > "$fixture/VERSION"
pack_release() {
- write_manifest "$fixture" > "$fixture/SHA256SUMS"
tar -czf "$archive" -C "$temporary/release" wrapper-1.0.0
printf '%s %s\n' "$(sha256 "$archive")" "$(basename "$archive")" > "$archive.sha256"
}
@@ -421,6 +391,7 @@ test_wrapper() (
# New boot artifacts must reach both distributions; retired files must disappear.
printf 'future format\000\377' > "$fixture/boot/new-runtime.dat"
+ printf 'obsolete manifest\n' > "$destination/SHA256SUMS"
pack_release
run_import
for prefix in '' agent/; do
@@ -435,7 +406,7 @@ test_wrapper() (
done
cmp "$WRAPPER_DIR/wrapper.conf" "$destination/wrapper.conf"
- # Preserve binary bytes, CRLF launchers, substitutions, modes, and manifest coverage.
+ # Preserve binary bytes, CRLF launchers, substitutions, and modes.
distribution="$destination/distribution"
cmp "$fixture/bin/service.sh" "$distribution/bin/server.sh"
cmp "$fixture/bin/service.bat" "$distribution/agent/bin/agent.bat"
@@ -451,7 +422,7 @@ test_wrapper() (
if grep -Eq '@[A-Za-z0-9_.]+@' "$distribution/conf/wrapper.conf" "$distribution/agent/conf/wrapper.conf"; then
fail "Unresolved placeholder"
fi
- verify_manifest "$destination"
+ [ ! -e "$destination/SHA256SUMS" ] || fail "Per-file manifest was generated"
cp -R "$destination" "$temporary/before"
# Bad downloads and invalid release contents must leave the previous import intact.
@@ -469,19 +440,12 @@ test_wrapper() (
pack_release
printf 'tampered\n' >> "$fixture/boot/wrapper.jar"
tar -czf "$archive" -C "$temporary/release" wrapper-1.0.0
- printf '%s %s\n' "$(sha256 "$archive")" "$(basename "$archive")" > "$archive.sha256"
expect_rejection
printf 'binary\000\377' > "$fixture/boot/wrapper.jar"
ln -s "$temporary/binary" "$fixture/boot/link"
pack_release
expect_rejection
rm "$fixture/boot/link"
- pack_release
- sed '/ VERSION$/d' "$fixture/SHA256SUMS" > "$temporary/incomplete-manifest"
- cp "$temporary/incomplete-manifest" "$fixture/SHA256SUMS"
- tar -czf "$archive" -C "$temporary/release" wrapper-1.0.0
- printf '%s %s\n' "$(sha256 "$archive")" "$(basename "$archive")" > "$archive.sha256"
- expect_rejection
echo "Wrapper importer tests passed"
# Exercise the downloader offline, including multiple links on the same HTML line.
@@ -510,7 +474,19 @@ test_wrapper() (
printf '<a href="wrapper-1.0.0.tar.gz">release</a><a HREF=\047wrapper-1.0.0.tar.gz\047>duplicate</a>\n' \
> "$temporary/index.html"
PATH="$temporary/mock-bin:$PATH" TMPDIR="$temporary/downloads" "$temporary/wrapper/update.sh"
- verify_manifest "$temporary/wrapper"
+ diff -r "$distribution" "$temporary/wrapper/distribution"
+ [ ! -e "$temporary/wrapper/SHA256SUMS" ] || fail "Per-file manifest was generated"
+ [ -z "$(ls -A "$temporary/downloads")" ] || fail "Downloads were not cleaned up"
+ # A remote update must reimport an unchanged version and regenerate configuration.
+ printf 'updated release jar\n' > "$fixture/boot/wrapper.jar"
+ printf '\nwrapper.logfile.maxfiles=7\n' >> "$temporary/wrapper/wrapper.conf"
+ pack_release
+ PATH="$temporary/mock-bin:$PATH" TMPDIR="$temporary/downloads" "$temporary/wrapper/update.sh"
+ for prefix in '' agent/; do
+ cmp "$fixture/boot/wrapper.jar" "$temporary/wrapper/distribution/${prefix}boot/wrapper.jar"
+ grep -qx 'wrapper.logfile.maxfiles=7' "$temporary/wrapper/distribution/${prefix}conf/wrapper.conf"
+ done
+ cmp "$fixture/VERSION" "$temporary/wrapper/VERSION"
[ -z "$(ls -A "$temporary/downloads")" ] || fail "Downloads were not cleaned up"
printf '<a href="wrapper-2.0.0.tar.gz">another release</a>\n' >> "$temporary/index.html"
if PATH="$temporary/mock-bin:$PATH" TMPDIR="$temporary/downloads" "$temporary/wrapper/update.sh" \
@@ -520,6 +496,30 @@ test_wrapper() (
[ -z "$(ls -A "$temporary/downloads")" ] || fail "Failed download was not cleaned up"
echo "Wrapper updater tests passed"
+ # Local updates must also import changed build outputs at the same version.
+ checkout="$temporary/local checkout"
+ mkdir -p "$checkout/dist/boot" "$checkout/resources"
+ printf '[package]\nversion = "2.0.0"\n' > "$checkout/Cargo.toml"
+ cp "$fixture/bin/service.sh" "$checkout/resources/App.sh.in"
+ cp "$fixture/bin/service.bat" "$checkout/resources/AppCommand.bat.in"
+ printf 'local jar\n' > "$checkout/dist/boot/wrapper.jar"
+ printf 'local binary\n' > "$checkout/dist/boot/wrapper-linux-x86-64"
+ "$temporary/wrapper/update.sh" "$checkout"
+ printf 'updated local jar\n' > "$checkout/dist/boot/wrapper.jar"
+ printf 'updated local binary\n' > "$checkout/dist/boot/wrapper-linux-x86-64"
+ printf '\nwrapper.restart.delay=2\n' >> "$temporary/wrapper/wrapper.conf"
+ "$temporary/wrapper/update.sh" "$checkout"
+ for prefix in '' agent/; do
+ for name in wrapper.jar wrapper-linux-x86-64; do
+ cmp "$checkout/dist/boot/$name" "$temporary/wrapper/distribution/${prefix}boot/$name"
+ done
+ cmp "$fixture/boot/wrapper-linux-arm-64" "$temporary/wrapper/distribution/${prefix}boot/wrapper-linux-arm-64"
+ grep -qx 'wrapper.restart.delay=2' "$temporary/wrapper/distribution/${prefix}conf/wrapper.conf"
+ done
+ [ "$(cat "$temporary/wrapper/VERSION")" = 2.0.0-local ]
+ [ ! -e "$temporary/wrapper/SHA256SUMS" ] || fail "Per-file manifest was generated"
+ echo "Wrapper local update tests passed"
+
# Build a small Maven-shaped package and check that content/mode regressions fail.
mkdir -p "$temporary/package/onedev-test" "$temporary/product/sandbox"
package="$temporary/package/onedev-test"
diff --git a/server-product/wrapper/wrapper.conf b/server-product/wrapper/wrapper.conf
index 24e458c1cb..03240258be 100644
--- a/server-product/wrapper/wrapper.conf
+++ b/server-product/wrapper/wrapper.conf
@@ -60,7 +60,5 @@ wrapper.ntservice.password=
# Zero allows unlimited startup/shutdown time. Java shutdown hooks run on stop.
wrapper.startup.timeout=0
wrapper.shutdown.timeout=0
-# Consecutive unexpected JVM failures are bounded to prevent a restart loop.
+# Delay before an application-requested restart. Unexpected JVM exits stop Wrapper.
wrapper.restart.delay=5
-wrapper.max_failed_invocations=5
-wrapper.successful_invocation_time=300