Skip to content

Commit d3d175d

Browse files
authored
Merge pull request #12 from byran77/auto-deletion-time
Add arguments to support offline nodes auto-deletion.
2 parents 8c799bb + b185aa9 commit d3d175d

File tree

1 file changed

+19
-9
lines changed

1 file changed

+19
-9
lines changed

SHIR/setup.ps1

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,18 @@ function RegisterNewNode {
3030
$AUTH_KEY,
3131
$NODE_NAME,
3232
$ENABLE_HA,
33-
$HA_PORT
33+
$HA_PORT,
34+
$ENABLE_AD,
35+
$AD_TIME
3436
)
3537

3638
Write-Log "Start registering a new SHIR node"
39+
Write-Log "Registering SHIR node with the node key: $($AUTH_KEY)"
40+
41+
if (!$NODE_NAME) {
42+
$NODE_NAME = $Env:COMPUTERNAME
43+
}
44+
Write-Log "Registering SHIR node with the node name: $($NODE_NAME)"
3745

3846
if ($ENABLE_HA -eq "true") {
3947
Write-Log "Enable High Availability"
@@ -46,8 +54,15 @@ function RegisterNewNode {
4654
Start-Sleep -Seconds 15
4755
}
4856

49-
if (!$NODE_NAME) {
50-
Start-Process $DmgcmdPath -Wait -ArgumentList "-RegisterNewNode", "$($AUTH_KEY)" -RedirectStandardOutput "C:\SHIR\register-out.txt" -RedirectStandardError "C:\SHIR\register-error.txt"
57+
if ($ENABLE_AD -eq "true") {
58+
Write-Log "Enable Expired Nodes Auto-Deletion"
59+
if (!$AD_TIME) {
60+
$AD_TIME = 600
61+
}
62+
63+
Write-Log "Node Expiration Time In Seconds: $($AD_TIME)"
64+
Start-Process $DmgcmdPath -Wait -ArgumentList "-RegisterNewNode", "$($AUTH_KEY)", "$($NODE_NAME)", "$($AD_TIME)" -RedirectStandardOutput "C:\SHIR\register-out.txt" -RedirectStandardError "C:\SHIR\register-error.txt"
65+
Start-Sleep -Seconds 15
5166
} else {
5267
Start-Process $DmgcmdPath -Wait -ArgumentList "-RegisterNewNode", "$($AUTH_KEY)", "$($NODE_NAME)" -RedirectStandardOutput "C:\SHIR\register-out.txt" -RedirectStandardError "C:\SHIR\register-error.txt"
5368
}
@@ -85,14 +100,9 @@ if (Check-Is-Registered) {
85100

86101
Start-Process $DmgcmdPath -Wait -ArgumentList "-Start"
87102
} elseif (Test-Path Env:AUTH_KEY) {
88-
Write-Log "Registering SHIR node with the node key: $($Env:AUTH_KEY)"
89-
Write-Log "Registering SHIR node with the node name: $($Env:NODE_NAME)"
90-
Write-Log "Registering SHIR node with the enable high availability flag: $($Env:ENABLE_HA)"
91-
Write-Log "Registering SHIR node with the tcp port: $($Env:HA_PORT)"
92-
93103
Start-Process $DmgcmdPath -Wait -ArgumentList "-Start"
94104

95-
RegisterNewNode $Env:AUTH_KEY $Env:NODE_NAME $Env:ENABLE_HA $Env:HA_PORT
105+
RegisterNewNode $Env:AUTH_KEY $Env:NODE_NAME $Env:ENABLE_HA $Env:HA_PORT $Env:ENABLE_AD $Env:AD_TIME
96106
} else {
97107
Write-Log "Invalid AUTH_KEY Value"
98108
exit 1

0 commit comments

Comments
 (0)