补齐源快照、资料预演、正式导入及工资核算的依赖链路。 新增版本化输入、逐段 FIFO、生成锁和结构化当月调整, 并提供默认关闭的周期采集、有限重试及 Windows 托管。 原始客户资料、私有配置及首页改动不纳入本次提交。 BREAKING CHANGE: 升级前需应用新增迁移,并通过 PAYROLL_MAKER_USER_ID 绑定实际工资制作人,否则业务只读。 旧单批次核算默认关闭;历史兼容需显式启用 PAYROLL_ALLOW_LEGACY_CALCULATION。生产启用和真实金额待验收。
36 lines
2.0 KiB
PowerShell
36 lines
2.0 KiB
PowerShell
[CmdletBinding()]
|
|
param(
|
|
[Parameter(Mandatory = $true)][ValidateSet('backend', 'worker', 'maintenance')][string]$Role,
|
|
[Parameter(Mandatory = $true)][string]$ProjectRoot,
|
|
[Parameter(Mandatory = $true)][string]$PythonPath,
|
|
[Parameter(Mandatory = $true)][string]$RuntimeDirectory,
|
|
[Parameter(Mandatory = $true)][string]$ConnectionFile,
|
|
[int]$ApiPort = 8000
|
|
)
|
|
. (Join-Path $PSScriptRoot 'TaskHost.Common.ps1')
|
|
$plan = Get-PayrollTaskPlan -ProjectRoot $ProjectRoot -PythonPath $PythonPath -RuntimeDirectory $RuntimeDirectory `
|
|
-ConnectionFile $ConnectionFile -TaskPath '\PayrollManagementSystem\' -ApiPort $ApiPort
|
|
if (Test-Path -LiteralPath $plan.StopFile) { exit 0 }
|
|
$env:T_PLUS_STOP_FILE = $plan.StopFile
|
|
$env:T_PLUS_ENABLED = 'true'
|
|
$env:T_PLUS_CONNECTION_FILE = $plan.ConnectionFile
|
|
$logs = Join-Path $plan.RuntimeDirectory 'logs'
|
|
New-Item -ItemType Directory -Path $logs -Force | Out-Null
|
|
$stamp = (Get-Date -Format 'yyyyMMdd-HHmmss') + '-' + [guid]::NewGuid().ToString('N').Substring(0,8)
|
|
$arguments = switch ($Role) {
|
|
'backend' { '-m uvicorn app.main:app --host 127.0.0.1 --port ' + $ApiPort }
|
|
'worker' { '-m app.cli tplus-worker --watch --connection-file ' + (Quote-TaskArgument $plan.ConnectionFile) + ' --stop-file ' + (Quote-TaskArgument $plan.StopFile) }
|
|
'maintenance' { '-m app.cli tplus-maintain --once --connection-file ' + (Quote-TaskArgument $plan.ConnectionFile) + ' --stop-file ' + (Quote-TaskArgument $plan.StopFile) }
|
|
}
|
|
$process = Start-Process -FilePath $plan.PythonPath -ArgumentList $arguments -WorkingDirectory (Join-Path $plan.ProjectRoot 'backend') `
|
|
-WindowStyle Hidden -PassThru -RedirectStandardOutput (Join-Path $logs "$Role-$stamp.out.log") `
|
|
-RedirectStandardError (Join-Path $logs "$Role-$stamp.err.log")
|
|
$processHandle = $process.Handle
|
|
while (-not $process.HasExited) {
|
|
if ($Role -eq 'backend' -and (Test-Path -LiteralPath $plan.StopFile)) { Stop-Process -Id $process.Id -ErrorAction Stop }
|
|
Start-Sleep -Seconds 1
|
|
$process.Refresh()
|
|
}
|
|
$process.WaitForExit()
|
|
exit $process.ExitCode
|