Add WinSW automatic update manifest

This commit is contained in:
2026-07-15 08:38:14 +00:00
parent 605c6b7d2a
commit 0eded90e6b
16 changed files with 111 additions and 17 deletions

4
.gitignore vendored
View File

@@ -6,5 +6,7 @@ NuGet/
*.user *.user
*.suo *.suo
# Lokalna konfiguracja wdrożeniowa; wzorcowa konfiguracja znajduje się w źródłach. # Lokalne konfiguracje wdrożeniowe; repozytorium zawiera wyłącznie wzorzec.
src/SmartB2B.Enova.Service/config/enova.json
release/config/enova.json
release/config/enova.local.json release/config/enova.local.json

View File

@@ -12,7 +12,7 @@ Dedykowana usługa Windows zastępująca proces Node na stanowiskach z enova365.
## Konfiguracja ## Konfiguracja
Plik `config/enova.json` zawiera portal WAMP, ścieżkę instalacji, alias bazy, operatora, definicję dokumentu, magazyn domyślny i tryb zapisu. Plik `config/enova.json` zawiera portal WAMP, ścieżkę instalacji, alias bazy, operatora, definicję dokumentu, magazyn domyślny i tryb zapisu. Repozytorium oraz paczka zawierają tylko `config/enova.json.sample`. Skrypt instalacyjny kopiuje wzorzec do `config/enova.json` wyłącznie wtedy, gdy lokalna konfiguracja jeszcze nie istnieje.
Sekrety nie są przechowywane w JSON-ie. Konto usługi musi widzieć dwie zmienne środowiskowe maszyny: Sekrety nie są przechowywane w JSON-ie. Konto usługi musi widzieć dwie zmienne środowiskowe maszyny:
@@ -38,7 +38,7 @@ Ostrzeżenie `NU1603` dotyczące `Soneta.Generator` jest takie samo jak w dział
Kontrola konfiguracji i dynamicznego ładowania, bez zapisu do bazy: Kontrola konfiguracji i dynamicznego ładowania, bez zapisu do bazy:
```powershell ```powershell
.\src\SmartB2B.Enova.Service\bin\Debug\net8.0\SmartB2B.Enova.Service.exe --check-config .\src\SmartB2B.Enova.Service\bin\Debug\net8.0\SmartB2B.Enova.Service.exe --config .\src\SmartB2B.Enova.Service\bin\Debug\net8.0\config\enova.json.sample --check-config
``` ```
## Publikacja i instalacja ## Publikacja i instalacja
@@ -47,9 +47,9 @@ Kontrola konfiguracji i dynamicznego ładowania, bez zapisu do bazy:
.\publish.ps1 .\publish.ps1
``` ```
Skrypt odtwarza katalog `release` z hostem, adapterem, konfiguracją i WinSW. Istniejąca konfiguracja `release/config/enova.json` jest zachowywana. Repozytorium zawiera również gotowy, skompilowany katalog `release`, więc na komputerze produkcyjnym nie trzeba instalować SDK. Przed instalacją: Skrypt odtwarza katalog `release` z hostem, adapterem, wzorcem konfiguracji i WinSW. Repozytorium zawiera również gotowy, skompilowany katalog `release`, więc na komputerze produkcyjnym nie trzeba instalować SDK. Przed instalacją:
1. Skopiuj katalog `release` na komputer produkcyjny i uzupełnij `release/config/enova.json`. 1. Skopiuj katalog `release` na komputer produkcyjny. Możesz skopiować `release/config/enova.json.sample` do `release/config/enova.json` i uzupełnić go przed instalacją; jeżeli tego nie zrobisz, `install.cmd` utworzy plik automatycznie.
2. Ustaw sekrety maszyny. 2. Ustaw sekrety maszyny.
3. Zatrzymaj starą usługę Node dla tego samego portalu WAMP. 3. Zatrzymaj starą usługę Node dla tego samego portalu WAMP.
4. Skonfiguruj usługę do pracy pod dedykowanym kontem Windows, które potrafi uruchomić Enovę, widzi jej bazę i licencję. 4. Skonfiguruj usługę do pracy pod dedykowanym kontem Windows, które potrafi uruchomić Enovę, widzi jej bazę i licencję.
@@ -66,3 +66,7 @@ Wycofanie polega na uruchomieniu `daemon/uninstall.cmd` i ponownym uruchomieniu
- Diagnostyka: `eu.smartb2b.sync.get_version`, `get_info`, `get_log`, `get_error_log`. - Diagnostyka: `eu.smartb2b.sync.get_version`, `get_info`, `get_log`, `get_error_log`.
Kod produkcyjny, testy oraz gotowa wersja instalacyjna znajdują się w tym repozytorium. Kod produkcyjny, testy oraz gotowa wersja instalacyjna znajdują się w tym repozytorium.
## Automatyczne aktualizacje
Przy starcie WinSW pobiera pliki aplikacji z `https://demo.smartb2b.eu/files/smartb2b-sync-enova/` zgodnie z listą `<download>` w `daemon/smartb2bsync-enova.xml`. Aktualizowane są program, biblioteki, adapter Enovy, skrypty, manifest usługi i `config/enova.json.sample`. Lokalny `config/enova.json` nie występuje na liście i nie jest nadpisywany. Sam `smartb2bsync-enova.exe` jest programem rozruchowym WinSW, dlatego nie aktualizuje samego siebie podczas pracy. `publish.ps1` porównuje zawartość gotowej paczki z manifestem i przerywa publikowanie, jeżeli którejkolwiek pozycji brakuje po jednej ze stron.

View File

@@ -7,6 +7,16 @@ if not exist "smartb2bsync-enova.exe" (
exit /b 1 exit /b 1
) )
if not exist "..\config" mkdir "..\config"
if not exist "..\config\enova.json" (
if not exist "..\config\enova.json.sample" (
echo Brak ..\config\enova.json.sample.
exit /b 1
)
copy /Y "..\config\enova.json.sample" "..\config\enova.json" >nul
echo Utworzono lokalna konfiguracje ..\config\enova.json.
)
smartb2bsync-enova.exe install smartb2bsync-enova.exe install
if errorlevel 1 exit /b %errorlevel% if errorlevel 1 exit /b %errorlevel%

View File

@@ -10,4 +10,35 @@
</log> </log>
<onfailure action="restart" delay="10 sec" /> <onfailure action="restart" delay="10 sec" />
<delayedAutoStart /> <delayedAutoStart />
<!--
WinSW pobiera te pliki przed uruchomieniem usługi. Lokalny plik
config\enova.json nie jest aktualizowany; odświeżany jest wyłącznie wzorzec.
smartb2bsync-enova.exe jest programem rozruchowym WinSW i nie może nadpisać
samego siebie podczas pracy.
-->
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/daemon/smartb2bsync-enova.xml" to="%BASE%\smartb2bsync-enova.xml" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/daemon/install.cmd" to="%BASE%\install.cmd" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/daemon/uninstall.cmd" to="%BASE%\uninstall.cmd" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.exe" to="%BASE%\..\SmartB2B.Enova.Service.exe" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.dll" to="%BASE%\..\SmartB2B.Enova.Service.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.deps.json" to="%BASE%\..\SmartB2B.Enova.Service.deps.json" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.runtimeconfig.json" to="%BASE%\..\SmartB2B.Enova.Service.runtimeconfig.json" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.pdb" to="%BASE%\..\SmartB2B.Enova.Service.pdb" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Contracts.dll" to="%BASE%\..\SmartB2B.Enova.Contracts.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Contracts.pdb" to="%BASE%\..\SmartB2B.Enova.Contracts.pdb" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/adapters/SmartB2B.Enova.Adapter.dll" to="%BASE%\..\adapters\SmartB2B.Enova.Adapter.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/Newtonsoft.Json.dll" to="%BASE%\..\Newtonsoft.Json.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/NewtonsoftMessagePack.dll" to="%BASE%\..\NewtonsoftMessagePack.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/System.Reactive.dll" to="%BASE%\..\System.Reactive.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/System.Runtime.InteropServices.WindowsRuntime.dll" to="%BASE%\..\System.Runtime.InteropServices.WindowsRuntime.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.dll" to="%BASE%\..\WampSharp.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.Default.Client.dll" to="%BASE%\..\WampSharp.Default.Client.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.NewtonsoftJson.dll" to="%BASE%\..\WampSharp.NewtonsoftJson.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.NewtonsoftMessagePack.dll" to="%BASE%\..\WampSharp.NewtonsoftMessagePack.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.WebSockets.dll" to="%BASE%\..\WampSharp.WebSockets.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/config/enova.json.sample" to="%BASE%\..\config\enova.json.sample" failOnError="false" />
</service> </service>

View File

@@ -21,12 +21,6 @@ $daemonSource = Join-Path $PSScriptRoot "daemon"
$winSwSource = Resolve-Path (Join-Path $daemonSource "smartb2bsync-enova.exe") $winSwSource = Resolve-Path (Join-Path $daemonSource "smartb2bsync-enova.exe")
$output = [System.IO.Path]::GetFullPath($OutputPath) $output = [System.IO.Path]::GetFullPath($OutputPath)
$daemonOutput = Join-Path $output "daemon" $daemonOutput = Join-Path $output "daemon"
$existingConfigurationPath = Join-Path $output "config\enova.json"
$existingConfiguration = if (Test-Path -LiteralPath $existingConfigurationPath) {
[System.IO.File]::ReadAllText($existingConfigurationPath)
} else {
$null
}
if ($output -eq [System.IO.Path]::GetPathRoot($output) -or $output.Length -lt 10) { if ($output -eq [System.IO.Path]::GetPathRoot($output) -or $output.Length -lt 10) {
throw "Niebezpieczna ścieżka wyjściowa: $output" throw "Niebezpieczna ścieżka wyjściowa: $output"
@@ -49,11 +43,23 @@ Copy-Item (Join-Path $daemonSource "smartb2bsync-enova.xml") $daemonOutput -Forc
Copy-Item (Join-Path $daemonSource "install.cmd") $daemonOutput -Force Copy-Item (Join-Path $daemonSource "install.cmd") $daemonOutput -Force
Copy-Item (Join-Path $daemonSource "uninstall.cmd") $daemonOutput -Force Copy-Item (Join-Path $daemonSource "uninstall.cmd") $daemonOutput -Force
if ($null -ne $existingConfiguration) { $downloadBaseUrl = "https://demo.smartb2b.eu/files/smartb2b-sync-enova/"
[System.IO.File]::WriteAllText( [xml]$manifest = Get-Content -Raw (Join-Path $daemonOutput "smartb2bsync-enova.xml")
(Join-Path $output "config\enova.json"), $downloadedFiles = @(
$existingConfiguration, $manifest.service.download |
[System.Text.UTF8Encoding]::new($false)) ForEach-Object { $_.from.Substring($downloadBaseUrl.Length).Replace('/', '\') } |
Sort-Object
)
$packagedFiles = @(
Get-ChildItem -Recurse -File $output |
ForEach-Object { $_.FullName.Substring($output.Length).TrimStart('\') } |
Where-Object { $_ -ne "daemon\smartb2bsync-enova.exe" } |
Sort-Object
)
$manifestDifferences = @(Compare-Object $packagedFiles $downloadedFiles)
if ($manifestDifferences.Count -ne 0) {
$details = $manifestDifferences | ForEach-Object { "$($_.SideIndicator) $($_.InputObject)" }
throw "Lista plików <download> nie odpowiada paczce:`n$($details -join "`n")"
} }
Write-Host "Gotowa usługa: $output" Write-Host "Gotowa usługa: $output"

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

Binary file not shown.

View File

@@ -7,6 +7,16 @@ if not exist "smartb2bsync-enova.exe" (
exit /b 1 exit /b 1
) )
if not exist "..\config" mkdir "..\config"
if not exist "..\config\enova.json" (
if not exist "..\config\enova.json.sample" (
echo Brak ..\config\enova.json.sample.
exit /b 1
)
copy /Y "..\config\enova.json.sample" "..\config\enova.json" >nul
echo Utworzono lokalna konfiguracje ..\config\enova.json.
)
smartb2bsync-enova.exe install smartb2bsync-enova.exe install
if errorlevel 1 exit /b %errorlevel% if errorlevel 1 exit /b %errorlevel%

View File

@@ -10,4 +10,35 @@
</log> </log>
<onfailure action="restart" delay="10 sec" /> <onfailure action="restart" delay="10 sec" />
<delayedAutoStart /> <delayedAutoStart />
<!--
WinSW pobiera te pliki przed uruchomieniem usługi. Lokalny plik
config\enova.json nie jest aktualizowany; odświeżany jest wyłącznie wzorzec.
smartb2bsync-enova.exe jest programem rozruchowym WinSW i nie może nadpisać
samego siebie podczas pracy.
-->
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/daemon/smartb2bsync-enova.xml" to="%BASE%\smartb2bsync-enova.xml" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/daemon/install.cmd" to="%BASE%\install.cmd" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/daemon/uninstall.cmd" to="%BASE%\uninstall.cmd" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.exe" to="%BASE%\..\SmartB2B.Enova.Service.exe" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.dll" to="%BASE%\..\SmartB2B.Enova.Service.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.deps.json" to="%BASE%\..\SmartB2B.Enova.Service.deps.json" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.runtimeconfig.json" to="%BASE%\..\SmartB2B.Enova.Service.runtimeconfig.json" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Service.pdb" to="%BASE%\..\SmartB2B.Enova.Service.pdb" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Contracts.dll" to="%BASE%\..\SmartB2B.Enova.Contracts.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/SmartB2B.Enova.Contracts.pdb" to="%BASE%\..\SmartB2B.Enova.Contracts.pdb" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/adapters/SmartB2B.Enova.Adapter.dll" to="%BASE%\..\adapters\SmartB2B.Enova.Adapter.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/Newtonsoft.Json.dll" to="%BASE%\..\Newtonsoft.Json.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/NewtonsoftMessagePack.dll" to="%BASE%\..\NewtonsoftMessagePack.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/System.Reactive.dll" to="%BASE%\..\System.Reactive.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/System.Runtime.InteropServices.WindowsRuntime.dll" to="%BASE%\..\System.Runtime.InteropServices.WindowsRuntime.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.dll" to="%BASE%\..\WampSharp.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.Default.Client.dll" to="%BASE%\..\WampSharp.Default.Client.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.NewtonsoftJson.dll" to="%BASE%\..\WampSharp.NewtonsoftJson.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.NewtonsoftMessagePack.dll" to="%BASE%\..\WampSharp.NewtonsoftMessagePack.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/WampSharp.WebSockets.dll" to="%BASE%\..\WampSharp.WebSockets.dll" failOnError="false" />
<download from="https://demo.smartb2b.eu/files/smartb2b-sync-enova/config/enova.json.sample" to="%BASE%\..\config\enova.json.sample" failOnError="false" />
</service> </service>

View File

@@ -13,7 +13,7 @@
<PackageReference Include="WampSharp.Default.Client" Version="23.8.1" /> <PackageReference Include="WampSharp.Default.Client" Version="23.8.1" />
</ItemGroup> </ItemGroup>
<ItemGroup> <ItemGroup>
<None Include="config/enova.json" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" /> <None Include="config/enova.json.sample" CopyToOutputDirectory="PreserveNewest" CopyToPublishDirectory="PreserveNewest" />
</ItemGroup> </ItemGroup>
<Target Name="BuildEnovaAdapter" BeforeTargets="Build"> <Target Name="BuildEnovaAdapter" BeforeTargets="Build">
<MSBuild Projects="../SmartB2B.Enova.Adapter/SmartB2B.Enova.Adapter.csproj" Targets="Build" Properties="Configuration=$(Configuration)" /> <MSBuild Projects="../SmartB2B.Enova.Adapter/SmartB2B.Enova.Adapter.csproj" Targets="Build" Properties="Configuration=$(Configuration)" />