abbasyk60 commited on
Commit
e564c3a
·
1 Parent(s): a1cf52c

Add keep-alive scripts and documentation

Browse files
Files changed (6) hide show
  1. .github/workflows/keep-alive.yml +15 -0
  2. KEEP-ALIVE.md +36 -0
  3. bot-err.log +0 -25
  4. bot.log +0 -3
  5. keep-alive.ps1 +31 -0
  6. test_api.py +0 -11
.github/workflows/keep-alive.yml ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ name: Keep Space Alive
2
+
3
+ on:
4
+ schedule:
5
+ - cron: '*/5 * * * *' # Every 5 minutes
6
+ workflow_dispatch: # Allow manual trigger
7
+
8
+ jobs:
9
+ ping:
10
+ runs-on: ubuntu-latest
11
+ steps:
12
+ - name: Ping Space
13
+ run: |
14
+ curl -s -o /dev/null -w "%{http_code}" https://abbasyk60-opencode.static.hf.space
15
+ echo " - Space pinged at $(date)"
KEEP-ALIVE.md ADDED
@@ -0,0 +1,36 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Keep-Alive Setup for HuggingFace Space
2
+
3
+ Your Static Space doesn't technically "sleep", but here's how to keep it active 24/7:
4
+
5
+ ## Option 1: UptimeRobot (Recommended - Free)
6
+
7
+ 1. Go to https://uptimerobot.com
8
+ 2. Create a free account
9
+ 3. Click "Add New Monitor"
10
+ 4. Settings:
11
+ - Monitor Type: HTTP(s)
12
+ - Friendly Name: OpenCode AI Agent
13
+ - URL: https://abbasyk60-opencode.static.hf.space
14
+ - Monitoring Interval: 5 minutes
15
+ 5. Click "Create Monitor"
16
+
17
+ That's it! UptimeRobot will ping your Space every 5 minutes.
18
+
19
+ ## Option 2: cron-job.org (Free)
20
+
21
+ 1. Go to https://cron-job.org
22
+ 2. Create a free account
23
+ 3. Click "Create Job"
24
+ 4. Settings:
25
+ - URL: https://abbasyk60-opencode.static.hf.space
26
+ - Schedule: Every 5 minutes
27
+ 5. Save
28
+
29
+ ## Option 3: Local Script (Windows)
30
+
31
+ Run the keep-alive script periodically:
32
+ ```powershell
33
+ .\keep-alive.ps1
34
+ ```
35
+
36
+ Or set up Windows Task Scheduler to run it every 5 minutes.
bot-err.log DELETED
@@ -1,25 +0,0 @@
1
- C:\Users\abbasyk\Documents\opencode-hf-space\node_modules\grammy\out\core\error.js:47
2
- return new GrammyError(`Call to '${method}' failed!`, err, method, payload);
3
- ^
4
-
5
- GrammyError: Call to 'getUpdates' failed! (409: Conflict: terminated by other getUpdates request; make sure that only one bot instance is running)
6
- at toGrammyError (C:\Users\abbasyk\Documents\opencode-hf-space\node_modules\grammy\out\core\error.js:47:12)
7
- at ApiClient.callApi (C:\Users\abbasyk\Documents\opencode-hf-space\node_modules\grammy\out\core\client.js:100:48)
8
- at process.processTicksAndRejections (node:internal/process/task_queues:104:5)
9
- at async Bot.fetchUpdates (C:\Users\abbasyk\Documents\opencode-hf-space\node_modules\grammy\out\bot.js:426:27)
10
- at async Bot.loop (C:\Users\abbasyk\Documents\opencode-hf-space\node_modules\grammy\out\bot.js:397:33)
11
- at async Bot.start (C:\Users\abbasyk\Documents\opencode-hf-space\node_modules\grammy\out\bot.js:318:9) {
12
- method: 'getUpdates',
13
- payload: {
14
- offset: 1,
15
- limit: undefined,
16
- timeout: 30,
17
- allowed_updates: undefined
18
- },
19
- ok: false,
20
- error_code: 409,
21
- description: 'Conflict: terminated by other getUpdates request; make sure that only one bot instance is running',
22
- parameters: {}
23
- }
24
-
25
- Node.js v24.18.0
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
bot.log DELETED
@@ -1,3 +0,0 @@
1
- [OK] Starting Telegram bot...
2
- [OK] Telegram bot is running!
3
- [OK] Chat ID filter: 6922119748
 
 
 
 
keep-alive.ps1 ADDED
@@ -0,0 +1,31 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # OpenCode Space Keep-Alive Script
2
+ # Pings the HuggingFace Space every 5 minutes to keep it active
3
+
4
+ $SpaceUrl = "https://abbasyk60-opencode.static.hf.space"
5
+ $LogFile = "$PSScriptRoot\keep-alive.log"
6
+
7
+ Write-Host "========================================="
8
+ Write-Host " OpenCode Space Keep-Alive"
9
+ Write-Host "========================================="
10
+ Write-Host ""
11
+ Write-Host "Space URL: $SpaceUrl"
12
+ Write-Host "Press Ctrl+C to stop"
13
+ Write-Host ""
14
+
15
+ while ($true) {
16
+ try {
17
+ $response = Invoke-WebRequest -Uri $SpaceUrl -Method Head -TimeoutSec 10 -UseBasicParsing
18
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
19
+ $logEntry = "[$timestamp] OK - Status: $($response.StatusCode)"
20
+ Write-Host $logEntry
21
+ Add-Content -Path $LogFile -Value $logEntry
22
+ } catch {
23
+ $timestamp = Get-Date -Format "yyyy-MM-dd HH:mm:ss"
24
+ $logEntry = "[$timestamp] ERROR - $($_.Exception.Message)"
25
+ Write-Host $logEntry -ForegroundColor Red
26
+ Add-Content -Path $LogFile -Value $logEntry
27
+ }
28
+
29
+ # Wait 5 minutes before next ping
30
+ Start-Sleep -Seconds 300
31
+ }
test_api.py DELETED
@@ -1,11 +0,0 @@
1
- import requests, json
2
-
3
- r = requests.post('https://opencode.ai/zen/v1/chat/completions',
4
- headers={'Authorization': 'Bearer sk-1IwuYl2EKD0bNtmoEPqBVuWQHlKlc7gN5VLFZnjBrGTUbg7O1376dM9eYg8AHaUv', 'Content-Type': 'application/json'},
5
- json={'model': 'deepseek-v4-flash-free', 'messages': [{'role': 'user', 'content': 'Say hello in one word'}], 'max_tokens': 200},
6
- timeout=60)
7
- print(f'Status: {r.status_code}')
8
- data = r.json()
9
- choice = data["choices"][0]["message"]
10
- print(f'content: [{choice.get("content", "")}]')
11
- print(f'reasoning: [{choice.get("reasoning_content", "")}]')