File size: 1,108 Bytes
e564c3a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
# OpenCode Space Keep-Alive Script
# Pings the HuggingFace Space every 5 minutes to keep it active

$SpaceUrl = "https://abbasyk60-opencode.static.hf.space"
$LogFile = "$PSScriptRoot\keep-alive.log"

Write-Host "========================================="
Write-Host "  OpenCode Space Keep-Alive"
Write-Host "========================================="
Write-Host ""
Write-Host "Space URL: $SpaceUrl"
Write-Host "Press Ctrl+C to stop"
Write-Host ""

while ($true) {
    try {
        $response = Invoke-WebRequest -Uri $SpaceUrl -Method Head -TimeoutSec 10 -UseBasicParsing
        $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        $logEntry = "[$timestamp] OK - Status: $($response.StatusCode)"
        Write-Host $logEntry
        Add-Content -Path $LogFile -Value $logEntry
    } catch {
        $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
        $logEntry = "[$timestamp] ERROR - $($_.Exception.Message)"
        Write-Host $logEntry -ForegroundColor Red
        Add-Content -Path $LogFile -Value $logEntry
    }
    
    # Wait 5 minutes before next ping
    Start-Sleep -Seconds 300
}