41 lines
932 B
Go
41 lines
932 B
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"flag"
|
|
"fmt"
|
|
"log"
|
|
"net/http"
|
|
"processSupervisor/handlers"
|
|
)
|
|
|
|
//go:embed templates/*.html templates/*/*.html
|
|
var templatesFS embed.FS
|
|
|
|
//go:embed static
|
|
var staticFS embed.FS
|
|
|
|
func main() {
|
|
|
|
port := flag.Uint("port", 9400, "listening port")
|
|
htop, err := handlers.NewHTopHandler(&templatesFS)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
mianPage, err := handlers.NewMainPage(&templatesFS)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticFS))))
|
|
|
|
http.HandleFunc("/taskmanager/htop", htop.UpdateHTop)
|
|
http.HandleFunc("/", mianPage.UpdateMainPage)
|
|
http.HandleFunc("/taskmanager/kill", handlers.KillHandler)
|
|
http.HandleFunc("/taskmanager/usage", handlers.UsageHandler)
|
|
|
|
log.Printf("Listening on http://localhost:%d\n", *port)
|
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
|
}
|