$ErrorActionPreference = "Stop" Get-Content "E:\wwwroot\.env" | ForEach-Object { $line = $_.Trim() if (-not $line -or $line.StartsWith("#")) { return } $i = $line.IndexOf("=") if ($i -lt 1) { return } Set-Item -Path ("Env:" + $line.Substring(0, $i).Trim()) -Value $line.Substring($i + 1).Trim().Trim('"') } # Inquiry ledger uses local Redis db1 (no ACL). Intranet REDIS_URL is ACL user+pass; # Jedis AUTH password-only against that instance returns WRONGPASS. Agent already uses 127.0.0.1. $env:YTD_REDIS_HOST = "127.0.0.1" $env:YTD_REDIS_PORT = "6379" if (-not $env:YTD_REDIS_DB) { $env:YTD_REDIS_DB = "1" } $env:YTD_REDIS_USERNAME = "" $env:YTD_REDIS_PASSWORD = "" Remove-Item Env:YTD_REDIS_USERNAME -ErrorAction SilentlyContinue Remove-Item Env:YTD_REDIS_PASSWORD -ErrorAction SilentlyContinue Write-Output ("redis_mode=local_noauth host=" + $env:YTD_REDIS_HOST + " db=" + $env:YTD_REDIS_DB) $sb = New-Object System.Text.StringBuilder [void]$sb.AppendLine("spring:") [void]$sb.AppendLine(" redis:") [void]$sb.AppendLine(" host: " + $env:YTD_REDIS_HOST) [void]$sb.AppendLine(" port: " + $env:YTD_REDIS_PORT) [void]$sb.AppendLine(" database: " + $env:YTD_REDIS_DB) [void]$sb.AppendLine(" username: ") [void]$sb.AppendLine(" password: ") $overlayPath = "E:\wwwroot\inquiry-new\config\application-redis-runtime.yml" [System.IO.File]::WriteAllText($overlayPath, $sb.ToString(), (New-Object System.Text.UTF8Encoding $false)) $env:LEDGER_PORT = "8180" $Java = "C:\yutongda\tools\jdk8\bin\java.exe" $Jar = "E:\wwwroot\inquiry-new\jeecg-system-start-3.5.3.jar" Set-Location "E:\wwwroot\inquiry-new" $arg = @( "-jar", $Jar, "--spring.profiles.active=inquiry", "--server.port=8180", "--spring.config.additional-location=optional:file:./config/", "--cas.prefixUrl=http://127.0.0.1/cas-disabled", "--jeecg.loginCaptchaEnabled=false", ("--spring.redis.host=" + $env:YTD_REDIS_HOST), ("--spring.redis.port=" + $env:YTD_REDIS_PORT), ("--spring.redis.database=" + $env:YTD_REDIS_DB), "--spring.redis.password=", "--spring.redis.username=" ) & $Java @arg