agent starting :D
This commit is contained in:
85
scripts/agentController.ps1
Normal file
85
scripts/agentController.ps1
Normal file
@@ -0,0 +1,85 @@
|
||||
Set-StrictMode -Version Latest
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
# config
|
||||
$Servers = @("appserver1", "appserver2") # hostnames or IPs
|
||||
$ServiceName = "MyAppService" # Windows service name (or pm2 process name logic)
|
||||
$AppDir= "C:\Users\matthes01\Documents\lst_v3"
|
||||
$RemoteTempZip = "C:\Windows\Temp\release.zip"
|
||||
$RemoteReleasesRoot = "C:\App\releases"
|
||||
$RemoteCurrent = "C:\App\current"
|
||||
|
||||
#--------------------------------------------------
|
||||
# below this shouldnt really need to be messed with
|
||||
#--------------------------------------------------
|
||||
|
||||
function Show-Menu {
|
||||
Clear-Host
|
||||
Write-Host "==============================="
|
||||
Write-Host " Deployment Menu "
|
||||
Write-Host "==============================="
|
||||
Write-Host "1. Build app"
|
||||
Write-Host "2. Deploy New Release"
|
||||
Write-Host "3. Restart Service"
|
||||
Write-Host "4. Exit"
|
||||
Write-Host ""
|
||||
}
|
||||
|
||||
function Select-Server {
|
||||
param([string[]]$List)
|
||||
for ($i = 0; $i -lt $List.Count; $i++) {
|
||||
Write-Host ("{0}. {1}" -f ($i+1), $List[$i])
|
||||
}
|
||||
$sel = Read-Host "Select server by number"
|
||||
if ($sel -match '^\d+$' -and [int]$sel -ge 1 -and [int]$sel -le $List.Count) {
|
||||
return $List[[int]$sel - 1]
|
||||
} else {
|
||||
Write-Host "Invalid selection"
|
||||
return $null
|
||||
}
|
||||
}
|
||||
|
||||
do {
|
||||
Show-Menu
|
||||
$choice = Read-Host "Select an option"
|
||||
|
||||
switch ($choice) {
|
||||
"1" {
|
||||
try {
|
||||
Push-Location $AppDir
|
||||
Write-Host "Running: npm run build in $AppDir"
|
||||
npm run build
|
||||
|
||||
Write-Host "Build completed successfully."
|
||||
Read-Host -Prompt "Press Enter to continue..."
|
||||
}
|
||||
catch {
|
||||
Write-Host "Build failed: $_"
|
||||
throw
|
||||
}
|
||||
finally {
|
||||
Pop-Location
|
||||
}
|
||||
}
|
||||
"2" {
|
||||
$server = Select-Server -List $Servers
|
||||
if ($null -ne $server) {
|
||||
$zip = Read-Host "Path to zip (local)"
|
||||
Deploy-ToServer -Server $server -ZipPath $zip
|
||||
}
|
||||
}
|
||||
"3" {
|
||||
Write-Host "Restart selected"
|
||||
psql -h localhost -p 5433 -U adm_cowch -d lst_dev -c "SELECT count(*) FROM public.logs;"
|
||||
}
|
||||
"4" {
|
||||
Write-Host "Exiting..."
|
||||
exit
|
||||
}
|
||||
default {
|
||||
Write-Host "Invalid selection"
|
||||
Start-Sleep -Seconds 2
|
||||
}
|
||||
}
|
||||
|
||||
} while ($choice -ne "3")
|
||||
Reference in New Issue
Block a user