54 lines
2.3 KiB
PowerShell
54 lines
2.3 KiB
PowerShell
# 重试 list + 看 Redis 连通
|
|
$ErrorActionPreference = 'Continue'
|
|
$loginBody = '{"username":"admin","password":"123456","captcha":"","checkKey":""}'
|
|
$login = Invoke-RestMethod -Uri 'http://127.0.0.1:8180/jeecgboot/sys/login' -Method POST -Body $loginBody -ContentType 'application/json;charset=UTF-8'
|
|
$token = $login.result.token
|
|
$h = @{ 'X-Access-Token' = $token }
|
|
1..3 | ForEach-Object {
|
|
try {
|
|
$r = Invoke-WebRequest -Uri 'http://127.0.0.1:8180/jeecgboot/inquiry/quoteTemplate/list?pageNo=1&pageSize=20' -Headers $h -UseBasicParsing -TimeoutSec 20
|
|
Write-Host ("try$_ status=$($r.StatusCode) body=" + $r.Content.Substring(0, [Math]::Min(400, $r.Content.Length)))
|
|
} catch {
|
|
Write-Host ("try$_ err=" + $_.Exception.Message)
|
|
}
|
|
Start-Sleep 1
|
|
}
|
|
# redis ping via .env
|
|
$envLines = Get-Content 'E:\wwwroot\.env'
|
|
$hostn='127.0.0.1'; $port='6379'; $db='1'; $rpw=$null
|
|
foreach ($line in $envLines) {
|
|
if ($line -match '^YTD_REDIS_HOST=(.+)$') { $hostn = $Matches[1].Trim().Trim('"') }
|
|
if ($line -match '^YTD_REDIS_PORT=(.+)$') { $port = $Matches[1].Trim().Trim('"') }
|
|
if ($line -match '^YTD_REDIS_DB=(.+)$') { $db = $Matches[1].Trim().Trim('"') }
|
|
if ($line -match '^YTD_REDIS_PASSWORD=(.+)$') { $rpw = $Matches[1].Trim().Trim('"') }
|
|
if ($line -match '^REDIS_URL=redis://:([^@]+)@([^:]+):(\d+)/(\d+)') {
|
|
$rpw=$Matches[1]; $hostn=$Matches[2]; $port=$Matches[3]; $db=$Matches[4]
|
|
}
|
|
}
|
|
Write-Host ("redis_cfg host=$hostn port=$port db=$db pw_len=" + ($(if($rpw){$rpw.Length}else{0})))
|
|
$cliCandidates = @(
|
|
'C:\yutongda\tools\Redis-x64-*\redis-cli.exe',
|
|
'E:\wwwroot\tools\*\redis-cli.exe',
|
|
'C:\Program Files\Redis\redis-cli.exe'
|
|
)
|
|
$cli = $null
|
|
foreach ($p in $cliCandidates) {
|
|
$hit = Get-Item $p -ErrorAction SilentlyContinue | Select-Object -First 1
|
|
if ($hit) { $cli = $hit.FullName; break }
|
|
}
|
|
if ($cli) {
|
|
Write-Host ("redis_cli=" + $cli)
|
|
if ($rpw) { & $cli -h $hostn -p $port -a $rpw -n $db PING }
|
|
else { & $cli -h $hostn -p $port -n $db PING }
|
|
} else {
|
|
Write-Host 'redis_cli_missing'
|
|
try {
|
|
$tcp = New-Object Net.Sockets.TcpClient
|
|
$iar = $tcp.BeginConnect($hostn, [int]$port, $null, $null)
|
|
$ok = $iar.AsyncWaitHandle.WaitOne(3000)
|
|
Write-Host ("tcp_connect=" + $ok + " connected=" + $tcp.Connected)
|
|
$tcp.Close()
|
|
} catch { Write-Host ("tcp_err=" + $_.Exception.Message) }
|
|
}
|
|
Write-Host 'RETRY_DONE'
|