@@ -1,6 +1,11 @@
11package main
22
33import (
4+ "net/http"
5+ "os"
6+
7+ _ "net/http/pprof" // profiling
8+
49 "github.com/opencode-ai/opencode/cmd"
510 "github.com/opencode-ai/opencode/internal/logging"
611)
@@ -10,5 +15,14 @@ func main() {
1015 logging.ErrorPersist("Application terminated due to unhandled panic")
1116 })
1217
18+ if os.Getenv("OPENCODE_PROFILE") != "" {
19+ go func() {
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)
23+ }
24+ }()
25+ }
26+
1327 cmd.Execute()
1428}