[MM-60648] Don't start server until all routes are registered (#28291)
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
20ed58906a
Коммит
3428cd15b6
@@ -11,6 +11,7 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||||
|
"github.com/mattermost/mattermost/server/v8/channels/manualtesting"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/web"
|
"github.com/mattermost/mattermost/server/v8/channels/web"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -337,6 +338,11 @@ func Init(srv *app.Server) (*API, error) {
|
|||||||
api.InitOutgoingOAuthConnection()
|
api.InitOutgoingOAuthConnection()
|
||||||
api.InitClientPerformanceMetrics()
|
api.InitClientPerformanceMetrics()
|
||||||
|
|
||||||
|
// If we allow testing then listen for manual testing URL hits
|
||||||
|
if *srv.Config().ServiceSettings.EnableTesting {
|
||||||
|
api.BaseRoutes.Root.Handle("/manualtest", api.APIHandler(manualtesting.ManualTest)).Methods(http.MethodGet)
|
||||||
|
}
|
||||||
|
|
||||||
srv.Router.Handle("/api/v4/{anything:.*}", http.HandlerFunc(api.Handle404))
|
srv.Router.Handle("/api/v4/{anything:.*}", http.HandlerFunc(api.Handle404))
|
||||||
|
|
||||||
InitLocal(srv)
|
InitLocal(srv)
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ import (
|
|||||||
|
|
||||||
"github.com/mattermost/mattermost/server/public/model"
|
"github.com/mattermost/mattermost/server/public/model"
|
||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/api4"
|
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app/slashcommands"
|
"github.com/mattermost/mattermost/server/v8/channels/app/slashcommands"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/store"
|
"github.com/mattermost/mattermost/server/v8/channels/store"
|
||||||
@@ -34,12 +33,7 @@ type TestEnvironment struct {
|
|||||||
Request *http.Request
|
Request *http.Request
|
||||||
}
|
}
|
||||||
|
|
||||||
// Init adds manualtest endpoint to the API.
|
func ManualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
||||||
func Init(api4 *api4.API) {
|
|
||||||
api4.BaseRoutes.Root.Handle("/manualtest", api4.APIHandler(manualTest)).Methods(http.MethodGet)
|
|
||||||
}
|
|
||||||
|
|
||||||
func manualTest(c *web.Context, w http.ResponseWriter, r *http.Request) {
|
|
||||||
// Let the world know
|
// Let the world know
|
||||||
c.Logger.Info("Setting up for manual test...")
|
c.Logger.Info("Setting up for manual test...")
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,6 @@ import (
|
|||||||
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
"github.com/mattermost/mattermost/server/public/shared/mlog"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/api4"
|
"github.com/mattermost/mattermost/server/v8/channels/api4"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/app"
|
"github.com/mattermost/mattermost/server/v8/channels/app"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/manualtesting"
|
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
"github.com/mattermost/mattermost/server/v8/channels/utils"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/web"
|
"github.com/mattermost/mattermost/server/v8/channels/web"
|
||||||
"github.com/mattermost/mattermost/server/v8/channels/wsapi"
|
"github.com/mattermost/mattermost/server/v8/channels/wsapi"
|
||||||
@@ -93,11 +92,12 @@ func runServer(configStore *config.Store, interruptChan chan os.Signal) error {
|
|||||||
}
|
}
|
||||||
}()
|
}()
|
||||||
|
|
||||||
api, err := api4.Init(server)
|
_, err = api4.Init(server)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
mlog.Error(err.Error())
|
mlog.Error(err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
wsapi.Init(server)
|
wsapi.Init(server)
|
||||||
web.New(server)
|
web.New(server)
|
||||||
|
|
||||||
@@ -107,11 +107,6 @@ func runServer(configStore *config.Store, interruptChan chan os.Signal) error {
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
||||||
// If we allow testing then listen for manual testing URL hits
|
|
||||||
if *server.Config().ServiceSettings.EnableTesting {
|
|
||||||
manualtesting.Init(api)
|
|
||||||
}
|
|
||||||
|
|
||||||
notifyReady()
|
notifyReady()
|
||||||
|
|
||||||
// wait for kill signal before attempting to gracefully shutdown
|
// wait for kill signal before attempting to gracefully shutdown
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user