Skip to content

Commit 69b83d4

Browse files
committed
Merge branch 'fix/s3-region-full-url'
2 parents 0a2d7e8 + 8b8c6d6 commit 69b83d4

2 files changed

Lines changed: 60 additions & 21 deletions

File tree

internal/api/ui/index.html

Lines changed: 11 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -46,8 +46,6 @@ <h1 class="auth-title">AutoAR</h1>
4646

4747
<nav class="sidebar-nav">
4848
<div class="nav-section">
49-
<div class="nav-section-label">Main</div>
50-
5149
<div class="nav-item active" id="nav-overview" data-label="Overview">
5250
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="3" y="3" width="7" height="7"/><rect x="14" y="3" width="7" height="7"/><rect x="14" y="14" width="7" height="7"/><rect x="3" y="14" width="7" height="7"/></svg></span>
5351
<span>Overview</span>
@@ -57,10 +55,6 @@ <h1 class="auth-title">AutoAR</h1>
5755
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"/><path d="m21 21-4.35-4.35"/></svg></span>
5856
<span>Scans</span>
5957
</div>
60-
</div>
61-
62-
<div class="nav-section">
63-
<div class="nav-section-label">Intelligence</div>
6458

6559
<div class="nav-item" id="nav-monitor" data-label="Monitor">
6660
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M1 12s4-8 11-8 11 8 11 8-4 8-11 8-11-8-11-8z"/><circle cx="12" cy="12" r="3"/></svg></span>
@@ -112,21 +106,17 @@ <h1 class="auth-title">AutoAR</h1>
112106
</div>
113107
</div>
114108

115-
</div>
116-
117-
<div class="nav-section">
118-
<div class="nav-section-label">System</div>
119-
<div class="nav-item" id="nav-r2" data-label="R2 Browser">
120-
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M21 8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16Z"/></svg></span>
121-
<span>R2 Browser</span>
122-
</div>
123-
<div class="nav-item" id="nav-report-templates" data-label="Report Templates">
124-
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M14 2H6a2 2 0 0 0-2 2v16a2 2 0 0 0 2 2h12a2 2 0 0 0 2-2V8z"/><polyline points="14 2 14 8 20 8"/><line x1="16" y1="13" x2="8" y2="13"/><line x1="16" y1="17" x2="8" y2="17"/><polyline points="10 9 9 9 8 9"/></svg></span>
125-
<span>Report Templates</span>
126-
</div>
127-
<div class="nav-item" id="nav-settings" data-label="Settings">
128-
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><path d="M12.22 2h-.44a2 2 0 0 0-2 2v.18a2 2 0 0 1-1 1.73l-.43.25a2 2 0 0 1-2 0l-.15-.08a2 2 0 0 0-2.73.73l-.22.38a2 2 0 0 0 .73 2.73l.15.1a2 2 0 0 1 1 1.72v.51a2 2 0 0 1-1 1.74l-.15.09a2 2 0 0 0-.73 2.73l.22.38a2 2 0 0 0 2.73.73l.15-.08a2 2 0 0 1 2 0l.43.25a2 2 0 0 1 1 1.73V20a2 2 0 0 0 2 2h.44a2 2 0 0 0 2-2v-.18a2 2 0 0 1 1-1.73l.43-.25a2 2 0 0 1 2 0l.15.08a2 2 0 0 0 2.73-.73l.22-.39a2 2 0 0 0-.73-2.73l-.15-.08a2 2 0 0 1-1-1.74v-.5a2 2 0 0 1 1-1.74l.15-.09a2 2 0 0 0 .73-2.73l-.22-.38a2 2 0 0 0-2.73-.73l-.15.08a2 2 0 0 1-2 0l-.43-.25a2 2 0 0 1-1-1.73V4a2 2 0 0 0-2-2z"/><circle cx="12" cy="12" r="3"/></svg></span>
129-
<span>Settings</span>
109+
<div class="nav-group">
110+
<div class="nav-item nav-group-head" id="nav-group-system" data-label="System" aria-expanded="false">
111+
<span class="nav-icon"><svg xmlns="http://www.w3.org/2000/svg" width="16" height="16" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect x="2" y="2" width="20" height="8" rx="2" ry="2"/><rect x="2" y="14" width="20" height="8" rx="2" ry="2"/><line x1="6" y1="6" x2="6.01" y2="6"/><line x1="6" y1="18" x2="6.01" y2="18"/></svg></span>
112+
<span>System</span>
113+
<svg class="nav-caret" xmlns="http://www.w3.org/2000/svg" width="14" height="14" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2.5" stroke-linecap="round" stroke-linejoin="round"><polyline points="9 18 15 12 9 6"/></svg>
114+
</div>
115+
<div class="nav-subitems" id="system-subnav" role="menu">
116+
<div class="nav-subitem" id="nav-r2" data-label="R2 Browser" role="menuitem">R2 Browser</div>
117+
<div class="nav-subitem" id="nav-report-templates" data-label="Report Templates" role="menuitem">Report Templates</div>
118+
<div class="nav-subitem" id="nav-settings" data-label="Settings" role="menuitem">Settings</div>
119+
</div>
130120
</div>
131121
</div>
132122
</nav>

internal/app/app.go

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@ import (
1111
"github.com/h0tak88r/AutoAR/internal/api"
1212
"github.com/h0tak88r/AutoAR/internal/db"
1313
"github.com/h0tak88r/AutoAR/internal/envloader"
14+
"github.com/h0tak88r/AutoAR/internal/scanner/monitor"
15+
"github.com/h0tak88r/AutoAR/internal/scanner/subdomainmonitor"
1416
"github.com/h0tak88r/AutoAR/internal/utils"
1517
)
1618

@@ -65,6 +67,12 @@ func StartAPI() error {
6567
// Ensure scans don't remain "running" across restarts (single-instance mode).
6668
reconcileStaleScansOnStartup()
6769

70+
// Monitor daemons are in-memory goroutines that don't survive a process restart,
71+
// but the DB keeps is_running=true — so the dashboard would show monitors "running"
72+
// while nothing actually polls. Resume the daemons for any still-running targets so
73+
// the persisted state is truthful and monitoring continues after a Docker restart.
74+
resumeMonitorsOnStartup()
75+
6876
// Pre-warm and keep the Programs catalogue cache fresh in the background so the
6977
// Programs page loads instantly instead of fetching ~1000 upstream calls per visit.
7078
if os.Getenv("DB_HOST") != "" {
@@ -120,6 +128,47 @@ func reconcileStaleScansOnStartup() {
120128
}
121129
}
122130

131+
// resumeMonitorsOnStartup restarts the monitor daemon goroutines (which don't survive
132+
// a process restart) when the DB still has monitor targets marked is_running, so polling
133+
// actually resumes instead of the dashboard merely showing a stale "running" flag.
134+
func resumeMonitorsOnStartup() {
135+
if err := db.Init(); err != nil {
136+
return
137+
}
138+
_ = db.EnsureSchema()
139+
140+
// Subdomain monitors.
141+
if targets, err := db.ListSubdomainMonitorTargets(); err == nil {
142+
running := 0
143+
for _, t := range targets {
144+
if t.IsRunning {
145+
running++
146+
}
147+
}
148+
if running > 0 {
149+
if err := subdomainmonitor.StartDaemon(); err != nil {
150+
log.Printf("[WARN] Could not resume subdomain monitor daemon: %v", err)
151+
} else {
152+
log.Printf("[INFO] Resumed subdomain monitor daemon for %d running target(s) after restart.", running)
153+
}
154+
}
155+
}
156+
157+
// URL monitors.
158+
if targets, err := db.ListMonitorTargets(); err == nil {
159+
running := 0
160+
for _, t := range targets {
161+
if t.IsRunning {
162+
running++
163+
}
164+
}
165+
if running > 0 {
166+
monitor.StartURLMonitorDaemon()
167+
log.Printf("[INFO] Resumed URL monitor daemon for %d running target(s) after restart.", running)
168+
}
169+
}
170+
}
171+
123172
// StartBoth starts the API server (legacy name kept for compatibility).
124173
func StartBoth() error {
125174
return StartAPI()

0 commit comments

Comments
 (0)