@@ -1,6 +1,11 @@
1package main
1package main
7+ _ "net/http/pprof" // profiling
4 "github.com/opencode-ai/opencode/cmd"
9 "github.com/opencode-ai/opencode/cmd"
5 "github.com/opencode-ai/opencode/internal/logging"
10 "github.com/opencode-ai/opencode/internal/logging"
@@ -10,5 +15,14 @@ func main() {
10 logging.ErrorPersist("Application terminated due to unhandled panic")
15 logging.ErrorPersist("Application terminated due to unhandled panic")
18+ if os.Getenv("OPENCODE_PROFILE") != "" {
20+ logging.Info("Serving pprof at localhost:6060")
21+ if httpErr := http.ListenAndServe("localhost:6060", nil); httpErr != nil {
22+ logging.Error("Failed to pprof listen: %v", httpErr)
13 cmd.Execute()
27 cmd.Execute()