File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -71,15 +71,27 @@ jobs:
7171 NODE_OPTIONS : --max-old-space-size=1024 # 限制为 1GB,避免占用过多内存
7272
7373 steps :
74- # 临时停止 SQL Server 释放内存
74+ # 临时停止 SQL Server 释放内存(可选)
7575 - name : 停止 SQL Server(释放内存)
7676 shell : powershell
77+ continue-on-error : true # 即使失败也继续执行
7778 run : |
7879 [Console]::OutputEncoding = [System.Text.Encoding]::UTF8
7980 Write-Host "Stopping SQL Server to free memory..."
80- Stop-Service -Name "MSSQLSERVER" -Force -ErrorAction SilentlyContinue
81- Stop-Service -Name "SQLSERVERAGENT" -Force -ErrorAction SilentlyContinue
82- Start-Sleep -Seconds 5
81+
82+ # 增加超时时间到 60 秒
83+ $service = Get-Service -Name "MSSQLSERVER" -ErrorAction SilentlyContinue
84+ if ($service -and $service.Status -eq 'Running') {
85+ $service.Stop()
86+ $service.WaitForStatus('Stopped', '00:01:00') # 等待最多 60 秒
87+ }
88+
89+ $agentService = Get-Service -Name "SQLSERVERAGENT" -ErrorAction SilentlyContinue
90+ if ($agentService -and $agentService.Status -eq 'Running') {
91+ $agentService.Stop()
92+ $agentService.WaitForStatus('Stopped', '00:00:30') # 等待最多 30 秒
93+ }
94+
8395 Write-Host "SQL Server stopped successfully"
8496
8597 # 下载构建产物(比完整代码库小很多)
You can’t perform that action at this time.
0 commit comments