diff --git a/config.json.example b/config.json.example index 2b5e9f0..7404013 100644 --- a/config.json.example +++ b/config.json.example @@ -19,5 +19,6 @@ }, "DelaySeconds": 15, "RandDelaySeconds": 5, - "MinDelaySeconds": 5 + "MinDelaySeconds": 5, + "Profiling": false } diff --git a/main.go b/main.go index ce790a7..32a51e2 100644 --- a/main.go +++ b/main.go @@ -11,6 +11,9 @@ import ( "encoding/json" // for config reading + "net/http" // base network package + _ "net/http/pprof" // expose profiling over the network + "github.com/gin-gonic/gin" api "github.com/wolffshots/phocus/v2/api" // api setup messages "github.com/wolffshots/phocus/v2/messages" // message structures @@ -19,7 +22,7 @@ import ( serial "github.com/wolffshots/phocus/v2/serial" // comms with inverter ) -const version = "v2.9.11" +const version = "v2.10.0" type Configuration struct { Serial struct { @@ -43,6 +46,7 @@ type Configuration struct { DelaySeconds int RandDelaySeconds int MinDelaySeconds int + Profiling bool } func ParseConfig(fileName string) (Configuration, error) { @@ -74,6 +78,12 @@ func main() { configuration, err := ParseConfig("config.json") + if err == nil && configuration.Profiling { + go func() { // start profiling endpoint in goroutine + log.Println(http.ListenAndServe("0.0.0.0:6060", nil)) + }() + } + if err != nil { log.Printf("Error parsing config: %v", err) os.Exit(1)