more abstraction and simple dashboard for processes
All checks were successful
Build Process Supervisor / build (amd64, .exe, windows) (push) Successful in 2m24s
Build Process Supervisor / build (amd64, , linux) (push) Successful in 2m36s
Build Process Supervisor / build (arm, 6, , linux) (push) Successful in 2m19s
Build Process Supervisor / build (arm64, , linux) (push) Successful in 2m14s

This commit is contained in:
Adrian Zürcher
2025-08-06 13:57:34 +02:00
parent e188813adf
commit 9f262c4a55
17 changed files with 428 additions and 564 deletions

26
main.go
View File

@@ -7,24 +7,23 @@ import (
"io/fs"
"log"
"net/http"
"processSupervisor/handlers"
"processSupervisor/htop"
"processSupervisor/mainPage"
)
//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)
cfgDir := flag.String("cfg", "./dist", "configuration directory")
htopHandler, err := htop.NewHTopHandler()
if err != nil {
panic(err)
}
mainPage, err := handlers.NewMainPage(&templatesFS)
mP, err := mainPage.NewMainPage(*cfgDir)
if err != nil {
panic(err)
}
@@ -36,13 +35,14 @@ func main() {
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
http.HandleFunc("/taskmanager/htop", htop.UpdateHTop)
http.HandleFunc("/", mainPage.UpdateMainPage)
http.HandleFunc("/start-process", mainPage.StartProcess)
http.HandleFunc("/stop-process", mainPage.StopProcess)
http.HandleFunc("/restart-process", mainPage.RestartProcess)
http.HandleFunc("/taskmanager/kill", handlers.KillHandler)
http.HandleFunc("/taskmanager/usage", handlers.UsageHandler)
http.HandleFunc("/taskmanager/htop", htopHandler.UpdateHTop)
http.HandleFunc("/", mP.LoadMainPage)
http.HandleFunc("/start-process", mP.StartProcess)
http.HandleFunc("/stop-process", mP.StopProcess)
http.HandleFunc("/restart-process", mP.RestartProcess)
http.HandleFunc("/processes", mP.UpdateMainPage)
http.HandleFunc("/taskmanager/kill", htop.KillHandler)
http.HandleFunc("/taskmanager/usage", htop.UsageHandler)
log.Printf("Listening on http://localhost:%d\n", *port)
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))