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
35 lines
765 B
Go
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)
|
|
}
|
|
}
|