build(controller): updates to not build the controller every time we update
this is incase we just want to test on a server then send this same build to all the other servers
This commit is contained in:
@@ -5,7 +5,8 @@ function Update-Server {
|
||||
[string]$AppRoot,
|
||||
[string]$Destination,
|
||||
[string]$Server,
|
||||
[string]$Token
|
||||
[string]$Token,
|
||||
[string]$ControllerBuild
|
||||
|
||||
)
|
||||
|
||||
@@ -26,7 +27,8 @@ function Update-Server {
|
||||
|
||||
if ($num) {
|
||||
$BuildNumber = $num + 1
|
||||
} else {
|
||||
}
|
||||
else {
|
||||
$BuildNumber = 1
|
||||
}
|
||||
}
|
||||
@@ -35,7 +37,13 @@ function Update-Server {
|
||||
$BuildNumber = $BuildNumber - 1
|
||||
|
||||
# Convert to string
|
||||
$BuildNumber = $BuildNumber.ToString()
|
||||
if ($ControllerBuild -eq "yes") {
|
||||
$BuildNumber = $BuildNumber.ToString()
|
||||
}
|
||||
else {
|
||||
$BuildNumber = ([int]$BuildNumber - 1).ToString()
|
||||
}
|
||||
|
||||
|
||||
# copy the latest build over
|
||||
|
||||
@@ -56,9 +64,11 @@ function Update-Server {
|
||||
$zipFile = Join-Path $BuildFolder "controllers-$BuildNumber.zip"
|
||||
Copy-Item -Path $zipFile -Destination "z:\" -Force
|
||||
Write-Host "Files copied to $($Server)"
|
||||
} catch {
|
||||
}
|
||||
catch {
|
||||
Write-Host "Error: $_"
|
||||
} finally {
|
||||
}
|
||||
finally {
|
||||
# Remove the mapped drive after copying
|
||||
if (Get-PSDrive -Name "z" -ErrorAction SilentlyContinue) {
|
||||
Write-Host "Removing mapped drive..."
|
||||
@@ -68,73 +78,78 @@ function Update-Server {
|
||||
|
||||
# do the stop services, unzip, and restart service and pool
|
||||
|
||||
$ControllerUpdate = {
|
||||
$ControllerUpdate = {
|
||||
param ($Server, $Token, $Destination, $BuildFile)
|
||||
|
||||
|
||||
write-host "Running the update process now"
|
||||
# Change the destination to be local
|
||||
$LocalPath = $Destination -replace '\$', ':'
|
||||
$BuildFileLoc = "$LocalPath\$BuildFile"
|
||||
write-host "Running the update process now"
|
||||
# Change the destination to be local
|
||||
$LocalPath = $Destination -replace '\$', ':'
|
||||
$BuildFileLoc = "$LocalPath\$BuildFile"
|
||||
|
||||
# where is nssm.exe
|
||||
$nssmPath= Join-Path $LocalPath "nssm.exe"
|
||||
$npmPath = "C:\Program Files\nodejs\npm.cmd"
|
||||
# where is nssm.exe
|
||||
#$nssmPath = Join-Path $LocalPath "nssm.exe"
|
||||
#$npmPath = "C:\Program Files\nodejs\npm.cmd"
|
||||
|
||||
Write-Host "Stopping the services to do the updates, pkgs and db changes."
|
||||
Write-Host "Stopping the services to do the updates, pkgs and db changes."
|
||||
|
||||
$Controller = "LST_ctl$(if ($Token -eq "usiow2") { "_2" })"
|
||||
$Wrapper = "LogisticsSupportTool$(if ($token -eq "usiow2") { "_2" })"
|
||||
$Controller = "LST_ctl$(if ($Token -eq "usiow2") { "_2" })"
|
||||
$Wrapper = "LogisticsSupportTool$(if ($token -eq "usiow2") { "_2" })"
|
||||
|
||||
Write-Host "Stopping $($Controller)"
|
||||
Stop-Service -DisplayName $Controller -Force
|
||||
Start-Sleep -Seconds 1
|
||||
Write-Host "Stopping $($Controller)"
|
||||
Stop-Service -DisplayName $Controller -Force
|
||||
Start-Sleep -Seconds 1
|
||||
|
||||
try {
|
||||
Stop-WebAppPool -Name $Wrapper -ErrorAction Stop
|
||||
Write-Host "Stopping $($Wrapper)"
|
||||
try {
|
||||
Stop-WebAppPool -Name $Wrapper -ErrorAction Stop
|
||||
|
||||
Start-Sleep -Seconds 2
|
||||
$state = (Get-WebAppPoolState -Name $Wrapper).Value
|
||||
Write-Host "Result: $state"
|
||||
} catch {
|
||||
Write-Error $_.Exception.Message
|
||||
}
|
||||
Start-Sleep -Seconds 2
|
||||
$state = (Get-WebAppPoolState -Name $Wrapper).Value
|
||||
Write-Host "Result: $state"
|
||||
}
|
||||
catch {
|
||||
Write-Error $_.Exception.Message
|
||||
}
|
||||
|
||||
|
||||
Write-Host "Unzipping the folder..."
|
||||
write-host $BuildFileLoc
|
||||
write-host $LocalPath
|
||||
Write-Host "Unzipping the folder..."
|
||||
#write-host $BuildFileLoc
|
||||
#write-host $LocalPath
|
||||
|
||||
# Extract the files to the build path
|
||||
try {
|
||||
# Expand the archive
|
||||
Expand-Archive -Path $BuildFileLoc -DestinationPath $LocalPath -Force
|
||||
} catch {
|
||||
Write-Host "Error: $_"
|
||||
exit 1 # Exit with a non-zero code if there's an error
|
||||
}
|
||||
# Extract the files to the build path
|
||||
try {
|
||||
# Expand the archive
|
||||
Expand-Archive -Path $BuildFileLoc -DestinationPath $LocalPath -Force
|
||||
}
|
||||
catch {
|
||||
Write-Host "Error: $_"
|
||||
exit 1 # Exit with a non-zero code if there's an error
|
||||
}
|
||||
|
||||
# Delete the zip file after extraction
|
||||
Write-Host "Deleting the zip file..."
|
||||
Remove-Item -Path $BuildFileLoc -Force
|
||||
# Delete the zip file after extraction
|
||||
Write-Host "Deleting the zip file..."
|
||||
Remove-Item -Path $BuildFileLoc -Force
|
||||
|
||||
Start-Sleep -Seconds 1
|
||||
Start-Sleep -Seconds 1
|
||||
|
||||
Write-Host "Starting $($Controller)"
|
||||
Start-Service -DisplayName $Controller
|
||||
Start-Sleep -Seconds 1
|
||||
Write-Host "Starting $($Controller)"
|
||||
Start-Service -DisplayName $Controller
|
||||
Start-Sleep -Seconds 1
|
||||
|
||||
try {
|
||||
Start-WebAppPool -Name $Wrapper
|
||||
Start-Sleep -Seconds 2
|
||||
$state = (Get-WebAppPoolState -Name $Wrapper).Value
|
||||
Write-Host "Result: $state"
|
||||
} catch {
|
||||
Write-Error $_.Exception.Message
|
||||
exit 1
|
||||
}
|
||||
Write-Host "Starting $($Wrapper)"
|
||||
try {
|
||||
Start-WebAppPool -Name $Wrapper
|
||||
Start-Sleep -Seconds 2
|
||||
$state = (Get-WebAppPoolState -Name $Wrapper).Value
|
||||
Write-Host "Result: $state"
|
||||
}
|
||||
catch {
|
||||
Write-Error $_.Exception.Message
|
||||
exit 1
|
||||
}
|
||||
|
||||
write-host "Controllers updated and restarted :D"
|
||||
write-host "Controllers updated and restarted :D"
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user