refactor: extract metrics-collector from fission-console, bump console to v1.3.12

This commit is contained in:
Naeel
2026-04-29 10:17:09 +03:00
parent abcd6bad36
commit df8bf0d476
10 changed files with 331 additions and 218 deletions
+40
View File
@@ -0,0 +1,40 @@
package main
import (
"log"
"net/http"
"os"
"time"
"metrics-collector/internal/api"
"metrics-collector/ui"
)
func main() {
port := os.Getenv("PORT")
if port == "" {
port = "8091"
}
srv := api.NewServer()
mux := http.NewServeMux()
mux.HandleFunc("/health", func(w http.ResponseWriter, _ *http.Request) {
w.Header().Set("Content-Type", "text/plain; charset=utf-8")
_, _ = w.Write([]byte("ok\n"))
})
mux.HandleFunc("/metrics", srv.HandleMetrics)
mux.Handle("/", ui.Handler())
httpSrv := &http.Server{
Addr: ":" + port,
Handler: mux,
ReadTimeout: 15 * time.Second,
WriteTimeout: 15 * time.Second,
}
log.Printf("metrics-collector listening on :%s", port)
if err := httpSrv.ListenAndServe(); err != nil {
log.Fatalf("listen: %v", err)
}
}