Move plugins under Channels (#18938)
* Move plugins under Channels We move all plugin related fields under *Channels. This essentially migrates several methods from being under *Server to under *Channels. We also move the plugin startup and shutdown code to be under Channels.Start and Channels.Shutdown. While here, we remove the getPluginPublicKeyFiles method which was a one-line method which uselessly returned an error. Lastly, we fix the product initialization order which was incorrect previously. Products are dependent on the main server. So startup should be products -> server. And shutdown should be server -> products. ```release-note NONE ``` * Added app layer ```release-note NONE ``` * Incorporate suggestions ```release-note NONE ```
Этот коммит содержится в:
коммит произвёл
GitHub
родитель
24248dc764
Коммит
25257d6ef6
@@ -47,7 +47,6 @@ import (
|
||||
"github.com/mattermost/mattermost-server/v6/einterfaces"
|
||||
"github.com/mattermost/mattermost-server/v6/jobs"
|
||||
"github.com/mattermost/mattermost-server/v6/model"
|
||||
"github.com/mattermost/mattermost-server/v6/plugin"
|
||||
"github.com/mattermost/mattermost-server/v6/services/awsmeter"
|
||||
"github.com/mattermost/mattermost-server/v6/services/cache"
|
||||
"github.com/mattermost/mattermost-server/v6/services/httpservice"
|
||||
@@ -108,10 +107,6 @@ type Server struct {
|
||||
goroutineCount int32
|
||||
goroutineExitSignal chan struct{}
|
||||
|
||||
PluginsEnvironment *plugin.Environment
|
||||
PluginConfigListenerId string
|
||||
PluginsLock sync.RWMutex
|
||||
|
||||
EmailService *email.Service
|
||||
|
||||
hubs []*Hub
|
||||
@@ -469,7 +464,7 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
|
||||
})
|
||||
|
||||
s.telemetryService = telemetry.New(s, s.Store, s.SearchEngine, s.Log)
|
||||
s.telemetryService = telemetry.New(New(ServerConnector(s.Channels())), s.Store, s.SearchEngine, s.Log)
|
||||
|
||||
emailService, err := email.NewService(email.ServiceConfig{
|
||||
ConfigFn: s.Config,
|
||||
@@ -689,15 +684,6 @@ func NewServer(options ...Option) (*Server, error) {
|
||||
|
||||
s.initPostMetadata()
|
||||
|
||||
s.initPlugins(c, *s.Config().PluginSettings.Directory, *s.Config().PluginSettings.ClientDirectory)
|
||||
s.AddConfigListener(func(prevCfg, cfg *model.Config) {
|
||||
if *cfg.PluginSettings.Enable {
|
||||
s.initPlugins(c, *cfg.PluginSettings.Directory, *s.Config().PluginSettings.ClientDirectory)
|
||||
} else {
|
||||
s.ShutDownPlugins()
|
||||
}
|
||||
})
|
||||
|
||||
// Dump the image cache if the proxy settings have changed. (need switch URLs to the correct proxy)
|
||||
s.AddConfigListener(func(oldCfg, newCfg *model.Config) {
|
||||
if (oldCfg.ImageProxySettings.Enable != newCfg.ImageProxySettings.Enable) ||
|
||||
@@ -1002,17 +988,7 @@ func (s *Server) Shutdown() {
|
||||
|
||||
defer sentry.Flush(2 * time.Second)
|
||||
|
||||
// Stop products.
|
||||
// This needs to happen before because products are dependent
|
||||
// on parent services.
|
||||
for name, product := range s.products {
|
||||
if err := product.Stop(); err != nil {
|
||||
mlog.Warn("Unable to cleanly stop product", mlog.String("name", name), mlog.Err(err))
|
||||
}
|
||||
}
|
||||
|
||||
s.HubStop()
|
||||
s.ShutDownPlugins()
|
||||
s.RemoveLicenseListener(s.licenseListenerId)
|
||||
s.RemoveLicenseListener(s.loggerLicenseListenerId)
|
||||
s.RemoveClusterLeaderChangedListener(s.clusterLeaderListenerId)
|
||||
@@ -1096,6 +1072,15 @@ func (s *Server) Shutdown() {
|
||||
|
||||
mlog.Info("Server stopped")
|
||||
|
||||
// Stop products.
|
||||
// This needs to happen last because products are dependent
|
||||
// on parent services.
|
||||
for name, product := range s.products {
|
||||
if err2 := product.Stop(); err2 != nil {
|
||||
mlog.Warn("Unable to cleanly stop product", mlog.String("name", name), mlog.Err(err2))
|
||||
}
|
||||
}
|
||||
|
||||
// shutdown main and notification loggers which will flush any remaining log records.
|
||||
timeoutCtx, timeoutCancel := context.WithTimeout(context.Background(), time.Second*15)
|
||||
defer timeoutCancel()
|
||||
@@ -1204,6 +1189,14 @@ func stripPort(hostport string) string {
|
||||
}
|
||||
|
||||
func (s *Server) Start() error {
|
||||
// Start products.
|
||||
// This needs to happen before because products are dependent on the HTTP server.
|
||||
for name, product := range s.products {
|
||||
if err := product.Start(); err != nil {
|
||||
return errors.Wrapf(err, "Unable to start %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
mlog.Info("Starting Server...")
|
||||
|
||||
var handler http.Handler = s.RootRouter
|
||||
@@ -1406,14 +1399,6 @@ func (s *Server) Start() error {
|
||||
mlog.Error("Error starting inter-cluster services", mlog.Err(err))
|
||||
}
|
||||
|
||||
// Start products.
|
||||
// This needs to happen after the server has started.
|
||||
for name, product := range s.products {
|
||||
if err := product.Start(); err != nil {
|
||||
return errors.Wrapf(err, "Unable to start %s", name)
|
||||
}
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
Ссылка в новой задаче
Block a user