|
@@ -23,23 +23,29 @@ func InitTriggerConfig() {
|
|
localTriggerIds := util.GetFirstLevelSubdirectories(config.CloudConfig.TriggersDir)
|
|
localTriggerIds := util.GetFirstLevelSubdirectories(config.CloudConfig.TriggersDir)
|
|
// 3 对比触发器列表,本地没有的则下载
|
|
// 3 对比触发器列表,本地没有的则下载
|
|
for _, trigger := range *cloudTriggers {
|
|
for _, trigger := range *cloudTriggers {
|
|
- label := util.GetFileNameWithoutExtension(config.CloudConfig.TriggersDir + trigger.TriggerScriptPath)
|
|
|
|
id := util.ToString(trigger.TriggerId)
|
|
id := util.ToString(trigger.TriggerId)
|
|
- triggerLocalPath := config.CloudConfig.TriggersDir + label + "_" + id + "/" + label + ".so"
|
|
|
|
- triggerLocalPaths = append(triggerLocalPaths, triggerLocalPath)
|
|
|
|
|
|
+ var triggerLocalPath string
|
|
|
|
+ triggerLocalDir := config.CloudConfig.TriggersDir + id + "/"
|
|
_ = util.CreateParentDir(triggerLocalPath)
|
|
_ = util.CreateParentDir(triggerLocalPath)
|
|
- contains, _ := util.ContainsElement(localTriggerIds, id)
|
|
|
|
- if contains { // 已存在的触发器不需要再次下载
|
|
|
|
|
|
+ hasIdDir, _ := util.ContainsElement(localTriggerIds, id)
|
|
|
|
+ hasLabelSo, soPaths := util.CheckSoFilesInDirectory(triggerLocalDir)
|
|
|
|
+ if hasIdDir && hasLabelSo { // 已存在的触发器不需要再次下载
|
|
|
|
+ triggerLocalPath = soPaths[0]
|
|
|
|
+ c_log.GlobalLogger.Info("触发器插件从 ", triggerLocalPath, " 存在。")
|
|
|
|
+ triggerLocalPaths = append(triggerLocalPaths, triggerLocalPath)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
|
|
+ label := util.GetFileNameWithoutExtension(config.CloudConfig.TriggersDir + trigger.TriggerScriptPath)
|
|
|
|
+ triggerLocalPath = config.CloudConfig.TriggersDir + id + "/" + label + ".so"
|
|
|
|
+ c_log.GlobalLogger.Info("下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
|
|
config.OssMutex.Lock()
|
|
config.OssMutex.Lock()
|
|
err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
err := config.OssBucket.GetObjectToFile(trigger.TriggerScriptPath, triggerLocalPath)
|
|
config.OssMutex.Unlock()
|
|
config.OssMutex.Unlock()
|
|
if err != nil {
|
|
if err != nil {
|
|
- c_log.GlobalLogger.Error("下载 oss 上的触发器插件失败:", err)
|
|
|
|
|
|
+ c_log.GlobalLogger.Error("下载 OSS 上的触发器插件失败:", err)
|
|
continue
|
|
continue
|
|
}
|
|
}
|
|
- c_log.GlobalLogger.Info("下载触发器插件从 ", trigger.TriggerScriptPath, " 到 ", triggerLocalPath)
|
|
|
|
|
|
+ triggerLocalPaths = append(triggerLocalPaths, triggerLocalPath)
|
|
}
|
|
}
|
|
|
|
|
|
// 下载所有触发器的文件
|
|
// 下载所有触发器的文件
|