|
@@ -182,18 +182,33 @@ var (
|
|
|
|
|
|
func InitTriggerConfig() {
|
|
|
c_log.GlobalLogger.Info("主节点加载触发器插件 - 开始。")
|
|
|
- // 下载所有触发器的文件
|
|
|
- for _, trigger := range config.PlatformConfig.TaskTriggers {
|
|
|
- triggerLocalPath := config.CloudConfig.TriggersDir + trigger.TriggerScriptPath
|
|
|
- _ = util.CreateParentDir(triggerLocalPath)
|
|
|
- c_log.GlobalLogger.Info("下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
|
|
|
- config.OssMutex.Lock()
|
|
|
- err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
|
- config.OssMutex.Unlock()
|
|
|
- if err != nil {
|
|
|
- c_log.GlobalLogger.Error("下载 oss 上的触发器插件失败:", err)
|
|
|
- continue
|
|
|
+ var triggerLocalPaths []string
|
|
|
+ if config.CloudConfig.TriggersOnline {
|
|
|
+ for _, trigger := range config.PlatformConfig.TaskTriggers {
|
|
|
+ triggerLocalPath := config.CloudConfig.TriggersDir + trigger.TriggerScriptPath
|
|
|
+ _ = util.CreateParentDir(triggerLocalPath)
|
|
|
+ config.OssMutex.Lock()
|
|
|
+ err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
|
+ config.OssMutex.Unlock()
|
|
|
+ if err != nil {
|
|
|
+ c_log.GlobalLogger.Error("下载 oss 上的触发器插件失败:", err)
|
|
|
+ continue
|
|
|
+ }
|
|
|
+ c_log.GlobalLogger.Info("下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
|
|
|
+ triggerLocalPaths = append(triggerLocalPaths, triggerLocalPath)
|
|
|
}
|
|
|
+ } else {
|
|
|
+ triggerLocalPaths = util.GetSoFilePaths(config.CloudConfig.TriggersDir)
|
|
|
+ for _, path := range triggerLocalPaths {
|
|
|
+ LabelMapTriggerId.Store(util.get, strconv.Itoa(trigger.TriggerId))
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for _, trigger := range config.PlatformConfig.TaskTriggers {
|
|
|
+ LabelMapTriggerId.Store(labelString, strconv.Itoa(trigger.TriggerId))
|
|
|
+ c_log.GlobalLogger.Info("主节点加载触发器插件:【ros topic】=", topic2, ",【触发器label】=", labelString, "【触发器ID】=", trigger.TriggerId)
|
|
|
+ }
|
|
|
+ // 下载所有触发器的文件
|
|
|
+ for _, triggerLocalPath := range triggerLocalPaths {
|
|
|
// 载入插件到数组
|
|
|
open, err := plugin.Open(triggerLocalPath)
|
|
|
if err != nil {
|
|
@@ -488,15 +503,12 @@ func InitTriggerConfig() {
|
|
|
continue
|
|
|
}
|
|
|
|
|
|
- label, err := open.Lookup("Label")
|
|
|
+ _, err = open.Lookup("Label")
|
|
|
if err != nil {
|
|
|
c_log.GlobalLogger.Error("加载本地插件 ", triggerLocalPath, " 中的 Label 方法失败。", err)
|
|
|
continue
|
|
|
}
|
|
|
- labelFunc := label.(func() string)
|
|
|
- labelString := labelFunc()
|
|
|
- LabelMapTriggerId.Store(labelString, strconv.Itoa(trigger.TriggerId))
|
|
|
- c_log.GlobalLogger.Info("主节点加载触发器插件:【ros topic】=", topic2, ",【触发器label】=", labelString, "【触发器ID】=", trigger.TriggerId)
|
|
|
+
|
|
|
}
|
|
|
c_log.GlobalLogger.Info("一共有", len(config.PlatformConfig.TaskTriggers), "个触发器。")
|
|
|
}
|