Skip to content

Open source AI coding agent. Designed for large projects and real world tasks.

after start hook for StartServer function

Dane Schneider0507e93158c3
diff --git a/app/server/main.go b/app/server/main.go
index 361e7f8b..172bea72 100644
--- a/app/server/main.go
+++ b/app/server/main.go
@@ -19,6 +19,6 @@ func main() {
routes.AddProxyableApiRoutes(r)
setup.MustLoadIp()
setup.MustInitDb()
- setup.StartServer(r, nil)
+ setup.StartServer(r, nil, nil)
os.Exit(0)
}
diff --git a/app/server/setup/setup.go b/app/server/setup/setup.go
index 2ee7cff5..0e1c1b23 100644
--- a/app/server/setup/setup.go
+++ b/app/server/setup/setup.go
@@ -59,7 +59,7 @@ func loggingMiddleware(next http.Handler) http.Handler {
})
}
-func StartServer(handler http.Handler, configureFn func(handler http.Handler) http.Handler) {
+func StartServer(handler http.Handler, configureFn func(handler http.Handler) http.Handler, afterStart func()) {
if os.Getenv("GOENV") == "development" {
log.Println("In development mode.")
}
@@ -108,6 +108,10 @@ func StartServer(handler http.Handler, configureFn func(handler http.Handler) ht
log.Println("Started Plandex server on port " + externalPort)
+ if afterStart != nil {
+ afterStart()
+ }
+
// Capture SIGTERM and SIGINT signals
sigTermChan := make(chan os.Signal, 1)