Skip to content

Commit

Permalink
some patches
Browse files Browse the repository at this point in the history
  • Loading branch information
chriskaliX committed Nov 27, 2023
1 parent e026115 commit 3168909
Show file tree
Hide file tree
Showing 7 changed files with 14 additions and 11 deletions.
8 changes: 5 additions & 3 deletions agent/plugin/manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ import (
)

var PluginManager = NewManager()
var ErrIgnore = errors.New("ignore")

var ErrAlreadyLoad = errors.New("already load")
var ErrPlgNotExists = errors.New("plugin not exists")

type Manager struct {
// plugins cache available SDK.IServer, key is plugin name
Expand Down Expand Up @@ -57,7 +59,7 @@ func (m *Manager) Load(ctx context.Context, cfg proto.Config) (err error) {
if plg, ok := m.Get(cfg.Name); ok && !plg.IsExited() {
if plg.Version() == cfg.Version {
// ignore this if already started
return ErrIgnore
return ErrAlreadyLoad
}
zap.S().Infof("start to shutdown plugin %s, version %s", plg.Name(), plg.Version())
plg.Shutdown()
Expand Down Expand Up @@ -94,7 +96,7 @@ func (pm *Manager) unRegist(name string) (err error) {

plg, ok := pm.plugins[name]
if !ok {
return fmt.Errorf("plugin %s not found", name)
return ErrPlgNotExists
}
plg.Shutdown()
delete(pm.plugins, name)
Expand Down
7 changes: 4 additions & 3 deletions agent/plugin/plugin.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,10 +38,11 @@ func Startup(ctx context.Context, wg *sync.WaitGroup) {
if cfg.Name == agent.Product {
continue
}
if err := PluginManager.Load(ctx, *cfg); err != nil && err != ErrIgnore {
zap.S().Errorf("plugin %s load failed: %s", cfg.Name, err.Error())
err := PluginManager.Load(ctx, *cfg)
if err == ErrAlreadyLoad {
zap.S().Infof("plugin %s has loaded already", cfg.Name)
} else {
zap.S().Infof("plugin %s is loaded successfully", cfg.Name)
zap.S().Errorf("plugin %s load failed: %s", cfg.Name, err.Error())
}
}
// 移除插件
Expand Down
2 changes: 1 addition & 1 deletion server/webconsole/api/static/frontend/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,6 @@
</head>
<body>
<div id="root"></div>
<script src="/umi.3a192c24.js"></script>
<script src="/umi.21a330d4.js"></script>

</body></html>

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading

0 comments on commit 3168909

Please sign in to comment.