
All checks were successful
Build Process Supervisor / build (amd64, .exe, windows) (push) Successful in 2m32s
Build Process Supervisor / build (amd64, , linux) (push) Successful in 2m41s
Build Process Supervisor / build (arm, 6, , linux) (push) Successful in 2m35s
Build Process Supervisor / build (arm64, , linux) (push) Successful in 2m31s
50 lines
1.2 KiB
Go
50 lines
1.2 KiB
Go
package main
|
|
|
|
import (
|
|
"embed"
|
|
"flag"
|
|
"fmt"
|
|
"io/fs"
|
|
"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)
|
|
}
|
|
|
|
mainPage, err := handlers.NewMainPage(&templatesFS)
|
|
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", 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)
|
|
|
|
log.Printf("Listening on http://localhost:%d\n", *port)
|
|
log.Fatal(http.ListenAndServe(fmt.Sprintf(":%d", *port), nil))
|
|
}
|