03-oct: superguardado automático
This commit is contained in:
@@ -31,6 +31,12 @@ $PluginDir = Join-Path $env:USERPROFILE '.config\opencode\plugins'
|
||||
$PluginDst = Join-Path $PluginDir 'omniroute-bootstrap.ts'
|
||||
$UserId = "$env:USERDOMAIN\$env:USERNAME"
|
||||
|
||||
# Monitor de estado (Telegram + correo + Jira)
|
||||
$TaskMonitor = 'Monitor Estado'
|
||||
$WatchdogMonitor = Join-Path $RepoRoot 'scripts\monitor_estado_watchdog.ps1'
|
||||
$PluginSrcMon = Join-Path $RepoRoot 'opencode\monitor-estado-bootstrap.ts'
|
||||
$PluginDstMon = Join-Path $PluginDir 'monitor-estado-bootstrap.ts'
|
||||
|
||||
Write-Host '== Instalando infraestructura global (OmniRoute + OpenCode) ==' -ForegroundColor Cyan
|
||||
|
||||
# 1) Plugin global de OpenCode ---------------------------------------------
|
||||
@@ -38,6 +44,9 @@ if (-not (Test-Path $PluginDir)) { New-Item -ItemType Directory -Force -Path $Pl
|
||||
Copy-Item -LiteralPath $PluginSrc -Destination $PluginDst -Force
|
||||
Write-Host " - Plugin global instalado en $PluginDst" -ForegroundColor Green
|
||||
|
||||
Copy-Item -LiteralPath $PluginSrcMon -Destination $PluginDstMon -Force
|
||||
Write-Host " - Plugin global instalado en $PluginDstMon" -ForegroundColor Green
|
||||
|
||||
# 2) Tarea programada ------------------------------------------------------
|
||||
if (-not (Test-Path $Watchdog)) { throw "No se encuentra el vigilante: $Watchdog" }
|
||||
|
||||
@@ -76,10 +85,43 @@ Register-ScheduledTask `
|
||||
|
||||
Write-Host " - Tarea '$TaskName' registrada -> $Watchdog" -ForegroundColor Green
|
||||
|
||||
# 2b) Tarea programada del Monitor de estado --------------------------------
|
||||
if (-not (Test-Path $WatchdogMonitor)) { throw "No se encuentra el vigilante: $WatchdogMonitor" }
|
||||
|
||||
if (Get-ScheduledTask -TaskName $TaskMonitor -ErrorAction SilentlyContinue) {
|
||||
Write-Host ' - Eliminando tarea anterior del monitor...' -ForegroundColor Yellow
|
||||
Unregister-ScheduledTask -TaskName $TaskMonitor -Confirm:$false
|
||||
}
|
||||
|
||||
$ActionMon = New-ScheduledTaskAction `
|
||||
-Execute $PwshExe `
|
||||
-Argument "-NoProfile -NonInteractive -ExecutionPolicy Bypass -WindowStyle Hidden -File `"$WatchdogMonitor`" -Once" `
|
||||
-WorkingDirectory $env:USERPROFILE
|
||||
|
||||
$SettingsMon = New-ScheduledTaskSettingsSet `
|
||||
-AllowStartIfOnBatteries `
|
||||
-DontStopIfGoingOnBatteries `
|
||||
-StartWhenAvailable `
|
||||
-MultipleInstances IgnoreNew
|
||||
$SettingsMon.ExecutionTimeLimit = 'PT0S'
|
||||
$SettingsMon.Hidden = $true
|
||||
|
||||
Register-ScheduledTask `
|
||||
-TaskName $TaskMonitor `
|
||||
-Action $ActionMon `
|
||||
-Trigger $Trigger `
|
||||
-Settings $SettingsMon `
|
||||
-Principal $Principal `
|
||||
-Description 'Arranca el Monitor de estado (Telegram + correo + Jira) al iniciar sesion.' `
|
||||
-Force | Out-Null
|
||||
|
||||
Write-Host " - Tarea '$TaskMonitor' registrada -> $WatchdogMonitor" -ForegroundColor Green
|
||||
|
||||
# 3) Arrancar --------------------------------------------------------------
|
||||
if (-not $NoStart) {
|
||||
Start-ScheduledTask -TaskName $TaskName
|
||||
Write-Host ' - Vigilante arrancado.' -ForegroundColor Yellow
|
||||
Start-ScheduledTask -TaskName $TaskMonitor
|
||||
Write-Host ' - Vigilantes arrancados.' -ForegroundColor Yellow
|
||||
}
|
||||
|
||||
# 4) Watchers de infraestructura (Telegram + recordatorios) -----------------
|
||||
|
||||
Reference in New Issue
Block a user