Skip to content

Commit

Permalink
fixed unable to start plugins issue
Browse files Browse the repository at this point in the history
  • Loading branch information
tikazyq committed Jun 3, 2022
1 parent 9810aef commit b373a57
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions constants/setting.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const (

const (
DefaultSettingPluginBaseUrl = "https://plugins.crawlab.cn"
DefaultSettingPluginBaseUrlDocker = "/app/plugins"
DefaultSettingPluginBaseUrlGitHub = "https://github.com"
DefaultSettingPluginGithubPublicOrg = "crawlab-team"
DefaultSettingPluginRepoPrefix = "plugin-"
Expand Down
14 changes: 9 additions & 5 deletions plugin/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -354,8 +354,8 @@ func (svc *Service) GetPublicPluginInfo(fullName string) (res interface{}, err e

func (svc *Service) installPublic(p interfaces.Plugin) (err error) {
if utils.IsDocker() {
p.SetInstallUrl(fmt.Sprintf("%s/%s", constants.DefaultSettingPluginBaseUrl, p.GetName()))
return svc.installRemote(p)
p.SetInstallUrl(fmt.Sprintf("%s/%s", constants.DefaultSettingPluginBaseUrlDocker, p.GetName()))
return svc.installLocal(p)
} else {
p.SetInstallUrl(fmt.Sprintf("%s/%s", svc.ps.PluginBaseUrl, p.GetFullName()))
return svc.installGit(p)
Expand Down Expand Up @@ -425,6 +425,7 @@ func (svc *Service) installLocal(p interfaces.Plugin) (err error) {
if err != nil {
return err
}
log.Debugf("_p: %v", _p)

// fill plugin data and save to db
if svc.cfgSvc.IsMaster() {
Expand All @@ -436,9 +437,11 @@ func (svc *Service) installLocal(p interfaces.Plugin) (err error) {
}
}

// build plugin binary and upload to fs
if svc._buildPlugin(pluginPath, p) != nil {
return err
// if not in docker or non-public plugin, build plugin binary and upload to fs
if !utils.IsDocker() || p.GetInstallType() != constants.PluginInstallTypePublic {
if svc._buildPlugin(pluginPath, p) != nil {
return err
}
}

log.Infof("local installed %s", p.GetInstallUrl())
Expand Down Expand Up @@ -467,6 +470,7 @@ func (svc *Service) installRemote(p interfaces.Plugin) (err error) {
}

// set plugin name
log.Debugf("_p: %v", _p)
if p.GetFullName() != "" && _p.GetFullName() == "" {
_p.SetFullName(p.GetFullName())
}
Expand Down

0 comments on commit b373a57

Please sign in to comment.