- 闇€姹傛枃妗e崌绾у埌 v0.5锛氳ˉ鍏呬簩缁寸爜娴锋姤淇濆瓨鏂囦欢鍚嶉粯璁ゆ牸寮忋€佸ぇ鏂囦欢涓婁紶涓夊眰闄愬埗锛圛IS+ASP.NET+鍓嶇锛夐儴缃茬害鏉熴€佹柊澧炵11绔犲紑鍙戣繘搴︾姸鎬佸綊妗o紙宸蹭笂绾垮姛鑳?宸蹭慨澶嶇己闄?宸茬煡闄愬埗/鍚庣画浼樺寲锛?- 鍚庣 FileController.Upload 澧炲姞 [RequestFormLimits(MultipartBodyLengthLimit=220_200_960)]锛屼慨澶?128MB multipart 涓婁紶琚嫆 - 鍓嶇 UploadView 浜岀淮鐮佹捣鎶ワ細淇 drawImage 缂╂斁閿欎綅銆侀《閮╨ogo/鏍囬鍨傜洿灞呬腑銆佸垎鍖烘爣棰橀棿璺濄€佸ぇ灏忎笌鏈夋晥鏈熷垎琛屾樉绀猴紱淇濆瓨鏂囦欢鍚嶆敼涓?鏂囦紶鏄撳彇浠剁爜-鍙栦欢鐮?鍘熸枃浠跺悕)-娴佹按鍙?png - 鏂板閮ㄧ讲鑴氭湰锛歛pply_backend.ps1 / force_dll.ps1锛坅pp_offline 瑙i攣DLL锛? ftp_fe.ps1 / ftp_diag.ps1 / ftp_apply.ps1 / _diag/check_dll.ps1 (閮ㄧ讲鎵嬪唽 IIS閮ㄧ讲涓嶧TP鍙戝竷.md 浠呭惈缂栫爜/BOM 宸紓锛屾湭绾冲叆鏈鎻愪氦)
79 lines
3.6 KiB
PowerShell
79 lines
3.6 KiB
PowerShell
# Apply new backend build via app_offline.htm (unlock inprocess DLLs) + full sync
|
|
$ErrorActionPreference = "Continue"
|
|
$FtpHost="116.198.221.125"; $FtpPort=21; $FtpUser="wenchuanyi"; $FtpPass="r7P^f*v7rFts"
|
|
$Root="D:\CodeBuddy\Pros\WenChuanyi"
|
|
$PublishDir = "$Root\backend\WenChuanyi.Api\bin\Release\net8.0\publish"
|
|
$DistDir = "$Root\frontend\dist"
|
|
$Stage = Join-Path $env:TEMP "wcy_publish_staging"
|
|
$RemoteRoot="/wwwroot"
|
|
$Log = "$Root\deploy\apply.log"
|
|
$fail=$false
|
|
Set-Content -Path $Log -Value "=== apply start $(Get-Date -Format 'yyyy-MM-dd HH:mm:ss') ===" -Encoding UTF8
|
|
function L([string]$m){ Add-Content -Path $Log -Value $m -Encoding UTF8 }
|
|
function New-FtpReq([string]$path,[string]$method,[int]$timeoutMs=90000){
|
|
$uri="ftp://${FtpHost}:${FtpPort}/"+$path.TrimStart('/')
|
|
$r=[System.Net.FtpWebRequest]::Create($uri)
|
|
$r.Method=$method; $r.Credentials=New-Object System.Net.NetworkCredential($FtpUser,$FtpPass)
|
|
$r.UsePassive=$true; $r.UseBinary=$true; $r.KeepAlive=$false; $r.Timeout=$timeoutMs
|
|
return $r
|
|
}
|
|
function Get-FtpSize([string]$p){
|
|
for($i=0;$i -lt 3;$i++){
|
|
try{ $r=New-FtpReq $p ([System.Net.WebRequestMethods+Ftp]::GetFileSize) 30000
|
|
$resp=$r.GetResponse(); $s=$resp.ContentLength; $resp.Close(); return $s }catch{ Start-Sleep -Seconds 2 }
|
|
}
|
|
return -1
|
|
}
|
|
function UpFile([string]$lp,[string]$rp){
|
|
$localSize=(Get-Item $lp).Length
|
|
$remoteSize=Get-FtpSize $rp
|
|
if($remoteSize -eq $localSize){ L "SKIP $rp"; return }
|
|
L "UPLOAD $rp (remote=$remoteSize local=$localSize)"
|
|
for($i=1;$i -le 4;$i++){
|
|
try{
|
|
$r=New-FtpReq $rp ([System.Net.WebRequestMethods+Ftp]::UploadFile) 300000
|
|
$b=[IO.File]::ReadAllBytes($lp); $r.ContentLength=$b.Length
|
|
$s=$r.GetRequestStream(); try{ $s.Write($b,0,$b.Length) } finally { $s.Close() }
|
|
$resp=$r.GetResponse(); try{ $resp.Close() }catch{}
|
|
Start-Sleep -Seconds 1
|
|
$after=Get-FtpSize $rp
|
|
if($after -eq $localSize){ L "OK $rp"; return }
|
|
L "VERIFYFAIL $rp (got $after)"
|
|
}catch{ L "RETRY($i) $rp : $($_.Exception.Message)" }
|
|
Start-Sleep -Seconds 4
|
|
}
|
|
L "FAIL $rp"; $script:fail=$true
|
|
}
|
|
function DelF([string]$rp){
|
|
try{ $r=New-FtpReq $rp ([System.Net.WebRequestMethods+Ftp]::DeleteFile)
|
|
$resp=$r.GetResponse(); try{$resp.Close()}catch{}; L "DEL $rp" }catch{ L "DEL skip $rp" }
|
|
Start-Sleep -Milliseconds 800
|
|
}
|
|
function UpDir([string]$ld,[string]$rd){
|
|
foreach($d in Get-ChildItem $ld -Directory){
|
|
$c="$rd/$($d.Name)"
|
|
$mr=New-FtpReq $c ([System.Net.WebRequestMethods+Ftp]::MakeDirectory) 30000
|
|
try{ $null=$mr.GetResponse() }catch{}
|
|
UpDir $d.FullName $c
|
|
}
|
|
foreach($f in Get-ChildItem $ld -File){ UpFile $f.FullName "$rd/$($f.Name)" }
|
|
}
|
|
# 1. stage
|
|
if(Test-Path $Stage){ Remove-Item $Stage -Recurse -Force }
|
|
New-Item -ItemType Directory -Path $Stage | Out-Null
|
|
Copy-Item "$DistDir\*" $Stage -Recurse -Force
|
|
Copy-Item "$PublishDir\*" $Stage -Recurse -Force
|
|
L "stage files: $((Get-ChildItem $Stage -File -Recurse).Count)"
|
|
# 2. app_offline to stop app & unlock DLLs
|
|
Set-Content -Path "$Stage\app_offline.htm" -Value "<html><body>maintenance</body></html>" -Encoding UTF8
|
|
UpFile "$Stage\app_offline.htm" "$RemoteRoot/app_offline.htm"
|
|
L "wait 6s for app shutdown..."
|
|
Start-Sleep -Seconds 6
|
|
# 3. full sync
|
|
UpDir $Stage $RemoteRoot
|
|
# 4. remove app_offline -> app auto-restart
|
|
DelF "$RemoteRoot/app_offline.htm"
|
|
Remove-Item $Stage -Recurse -Force
|
|
if($fail){ L "RESULT=PARTIAL_FAIL" } else { L "RESULT=OK" }
|
|
L "=== apply end $(Get-Date -Format 'HH:mm:ss') ==="
|