-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathget_diff_task.ps1
More file actions
44 lines (36 loc) · 1.11 KB
/
get_diff_task.ps1
File metadata and controls
44 lines (36 loc) · 1.11 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
param(
[Parameter(Mandatory = $false)]
[ValidateSet("all", "main", "test")]
[string]$Net = "main",
[Parameter(Mandatory = $false)]
[string]$MetricsHost = $env:CKB_SYNC_METRICS_HOST
)
$ErrorActionPreference = "Continue"
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
$taskLog = Join-Path $scriptDir "get_diff_task.log"
function Write-TaskLog {
param([string]$Message)
$line = "{0} {1}" -f (Get-Date).ToString("yyyy-MM-dd HH:mm:ss"), $Message
Add-Content -LiteralPath $taskLog -Encoding UTF8 -Value $line
}
try {
Set-Location -LiteralPath $scriptDir
Write-TaskLog "start net=$Net"
$scriptArgs = @{
Net = $Net
}
if (-not [string]::IsNullOrWhiteSpace($MetricsHost)) {
$scriptArgs.MetricsHost = $MetricsHost
}
$output = & (Join-Path $scriptDir "get_diff.ps1") @scriptArgs 2>&1
foreach ($line in $output) {
Write-TaskLog "$line"
}
$exitCode = if ($null -eq $LASTEXITCODE) { 0 } else { $LASTEXITCODE }
Write-TaskLog "done exit=$exitCode"
exit 0
}
catch {
Write-TaskLog "error: $($_.Exception.Message)"
exit 1
}