From 2b1af100a2402e65b44a929489754949198a19df Mon Sep 17 00:00:00 2001
From: xyc <jc_xiong@hotmail.com>
Date: 星期二, 06 十月 2026 00:29:34 +0800
Subject: [PATCH] fix(holiday): 国省道环比基期改为纯备用值,不进环比计算
---
deploy-templates/backend/install-service.ps1 | 80 ++++++++++++++++++++++++++++-----------
1 files changed, 57 insertions(+), 23 deletions(-)
diff --git a/deploy-templates/backend/install-service.ps1 b/deploy-templates/backend/install-service.ps1
index 2b8f094..8ff8a19 100644
--- a/deploy-templates/backend/install-service.ps1
+++ b/deploy-templates/backend/install-service.ps1
@@ -1,8 +1,8 @@
-锘�<#
+<#
Install / update / remove the TrafficAudit backend as a Windows service.
The service is a WinSW (Windows Service Wrapper) host: trafficAudit.exe reads
- trafficAudit.xml and runs "java -jar traffic-audit-server-<version>.jar".
+ trafficAudit.xml and runs "java -jar traffic-audit-server.jar".
Because it is a real Windows service it starts at boot with no user logged on,
is listed in services.msc / Get-Service, and is restarted by the Service
Control Manager when the java process dies.
@@ -44,6 +44,21 @@
$config = Join-Path $root 'trafficAudit.xml'
$appConfig = Join-Path $root 'application.yml'
$serviceId = 'TrafficAuditBackend'
+
+# Any terminating error below lands here instead of dumping a raw stack trace
+# at the operator. The line number is kept so a copy of this window is enough
+# to diagnose a report.
+trap {
+ Write-Host ''
+ Write-Host '=============================================================='
+ Write-Host ' ERROR: the installer stopped before finishing.'
+ Write-Host (' ' + $_.Exception.Message)
+ Write-Host (' at line ' + $_.InvocationInfo.ScriptLineNumber + ' of install-service.ps1')
+ Write-Host ' The service may not be installed. Send this window text to the'
+ Write-Host ' developer if the reason is not obvious.'
+ Write-Host '=============================================================='
+ exit 1
+}
function Assert-Admin {
$identity = [Security.Principal.WindowsIdentity]::GetCurrent()
@@ -146,6 +161,45 @@
}
}
+function Test-AppConfigPassword {
+ param([string]$Path)
+
+ # Returns $true when the datasource password looks usable. Prints a WARN and
+ # returns $false for the states that break startup with
+ # "Access denied ... (using password: NO)": missing file / empty value / placeholder.
+ if (-not (Test-Path -LiteralPath $Path)) {
+ Write-Host 'WARN: application.yml is missing next to the jar.'
+ Write-Host ' The built-in password placeholder resolves to an empty string and startup will fail with'
+ Write-Host " Java SQLException: Access denied for user 'root'@'localhost' (using password: NO)."
+ return $false
+ }
+
+ $line = Select-String -LiteralPath $Path -Pattern '^\s*password\s*:' | Select-Object -First 1
+ if (-not $line) {
+ Write-Host "WARN: no 'password:' entry found in application.yml; check the datasource block."
+ return $false
+ }
+
+ # Trim() takes a single char, so strip whitespace, then one quote kind at a
+ # time. Passing a 2-char string here throws
+ # "cannot convert value ... to type System.Char" and aborts the script.
+ $value = $line.Line -replace '^\s*password\s*:\s*', ''
+ $value = $value.Trim()
+ $value = $value.Trim("'")
+ $value = $value.Trim('"')
+
+ if ($value -eq '') {
+ Write-Host "WARN: spring.datasource.password is empty in application.yml; startup may fail with '(using password: NO)'."
+ return $false
+ }
+ if ($value -match '[^\x00-\x7F]') {
+ Write-Host 'WARN: the datasource password contains non-ASCII characters.'
+ Write-Host ' If it is still the Chinese placeholder text, replace it with the real MySQL password first.'
+ return $false
+ }
+ return $true
+}
+
# ---------- read-only status: no elevation needed ----------
if ($Status) {
$service = Get-ServiceState
@@ -197,27 +251,7 @@
if (-not (Test-Path $wrapper)) {
throw "Missing wrapper executable: $wrapper`nRebuild the deploy package with pack-deploy.ps1 (it provides WinSW), or copy WinSW-x64.exe here renamed to trafficAudit.exe."
}
-$passwordOk = $false
-if (-not (Test-Path $appConfig)) {
- Write-Host "WARN: application.yml is missing next to the jar."
- Write-Host " The built-in password placeholder resolves to an empty string and startup will fail with"
- Write-Host " Java SQLException: Access denied for user 'root'@'localhost' (using password: NO)."
-} else {
- $line = Select-String -LiteralPath $appConfig -Pattern '^\s*password\s*:' | Select-Object -First 1
- if (-not $line) {
- Write-Host "WARN: no 'password:' entry found in application.yml; check the datasource block."
- } else {
- $value = ($line.Line -replace '^\s*password\s*:\s*', '').Trim(' ''', '"')
- if ($value -eq '') {
- Write-Host "WARN: spring.datasource.password is empty in application.yml; startup may fail with '(using password: NO)'."
- } elseif ($value -match '[^\x00-\x7F]') {
- Write-Host "WARN: the datasource password contains non-ASCII characters."
- Write-Host " If it is still the Chinese placeholder text, replace it with the real MySQL password first."
- } else {
- $passwordOk = $true
- }
- }
-}
+$passwordOk = Test-AppConfigPassword -Path $appConfig
$java = Resolve-JavaPath -Explicit $JavaPath
Set-WrapperJavaPath -JavaExe $java
--
Gitblit v1.9.1