Open source AI coding agent. Designed for large projects and real world tasks.
Go aiai-agentsai-developer-toolsai-toolsclicommand-linedeveloper-toolsgitgolanggpt-4llmopenaipolyglot-programmingterminalterminal-basedterminal-ui
hook for health checks, no need for hostname checking on oss routing
Dane Schneider0e791cd8d64a
diff --git a/app/server/hooks/hooks.go b/app/server/hooks/hooks.goindex 06f03619..c78341cf 100644--- a/app/server/hooks/hooks.go+++ b/app/server/hooks/hooks.go@@ -9,6 +9,8 @@ import ()const (+ HealthCheck = "health_check"+CreateAccount = "create_account"WillCreatePlan = "will_create_plan"WillTellPlan = "will_tell_plan"diff --git a/app/server/main.go b/app/server/main.goindex e8b55c9f..c632c393 100644--- a/app/server/main.go+++ b/app/server/main.go@@ -1,9 +1,7 @@package mainimport (- "fmt""log"- "os""plandex-server/setup""github.com/gorilla/mux"@@ -13,25 +11,9 @@ func main() {// Configure the default logger to include milliseconds in timestampslog.SetFlags(log.LstdFlags | log.Lmicroseconds)- var domain string- if os.Getenv("DOMAIN") != "" {- domain = os.Getenv("DOMAIN")- } else if os.Getenv("GOENV") == "development" {- domain = "localhost"- } else {- panic(fmt.Errorf("DOMAIN environment variable is required unless GOENV is set to development"))- }-r := mux.NewRouter()- var apiRouter *mux.Router- if os.Getenv("GOENV") == "development" {- apiRouter = r- } else {- apiRouter = r.Host("api." + domain).Subrouter()- }-setup.MustLoadIp()setup.MustInitDb()- setup.StartServer(apiRouter)+ setup.StartServer(r)}diff --git a/app/server/routes/routes.go b/app/server/routes/routes.goindex 358f9c83..8001233e 100644--- a/app/server/routes/routes.go+++ b/app/server/routes/routes.go@@ -2,15 +2,26 @@ package routesimport ("fmt"+ "log""net/http""os""plandex-server/handlers"+ "plandex-server/hooks""github.com/gorilla/mux")func AddApiRoutes(r *mux.Router) {r.HandleFunc("/health", func(w http.ResponseWriter, r *http.Request) {++ _, apiErr := hooks.ExecHook(hooks.HealthCheck, hooks.HookParams{})++ if apiErr != nil {+ log.Printf("Error in health check hook: %v\n", apiErr)+ http.Error(w, apiErr.Msg, apiErr.Status)+ return+ }+fmt.Fprint(w, "OK")})