Files
watcher/main.go
primal efb246ff1e Add routes.go and main.go - Phase 4 complete
routes.go: HTTP route registration with OAuth middleware
- Converted all handlers from (c *Crawler) to (d *Dashboard)
- Removed url.1440.news short URL handling (belongs in shortener service)
- Removed /internal/crawl endpoint (requires crawler)

main.go: Entry point for standalone dashboard service
- Uses NewDashboard with connection string from DATABASE_URL
- Starts stats update loop and HTTP server
2026-02-02 12:59:22 -05:00

35 lines
765 B
Go

package main
import (
"fmt"
"os"
)
func main() {
// Get database connection string from environment (or empty for defaults)
connString := os.Getenv("DATABASE_URL")
// Create dashboard instance (handles DB connection internally)
dashboard, err := NewDashboard(connString)
if err != nil {
fmt.Fprintf(os.Stderr, "Failed to initialize dashboard: %v\n", err)
os.Exit(1)
}
defer dashboard.db.Close()
// Start background stats update loop
go dashboard.StartStatsLoop()
// Get listen address from environment or use default
addr := os.Getenv("DASHBOARD_ADDR")
if addr == "" {
addr = "0.0.0.0:4321"
}
// Start HTTP server
if err := dashboard.StartServer(addr); err != nil {
fmt.Fprintf(os.Stderr, "Server error: %v\n", err)
os.Exit(1)
}
}