
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
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"flag"
|
|
"fmt"
|
|
"io/fs"
|
|
"log"
|
|
"net/http"
|
|
"processSupervisor/htop"
|
|
"processSupervisor/mainPage"
|
|
)
|
|
|
|
//go:embed static
|
|
var staticFS embed.FS
|
|
|
|
func main() {
|
|
|
|
port := flag.Uint("port", 9400, "listening port")
|
|
cfgDir := flag.String("cfg", "./dist", "configuration directory")
|
|
htopHandler, err := htop.NewHTopHandler()
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
mP, err := mainPage.NewMainPage(*cfgDir)
|
|
if err != nil {
|
|
panic(err)
|
|
}
|
|
|
|
staticSub, err := fs.Sub(staticFS, "static")
|
|
if err != nil {
|
|
log.Fatal(err)
|
|
}
|
|
|
|
http.Handle("/static/", http.StripPrefix("/static/", http.FileServer(http.FS(staticSub))))
|
|
|
|
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))
|
|
}
|