Esempio n. 1
0
func (p *DmSrcProvider) getNextMsg() ([][]byte, error) {
	var files [][]byte
	var err error
	var lastFile string
	var fileList []string
	var newFileList []string

	for path, lastRecordFile := range p.lastFileMap {
		lastFile, err = common.ReadFile(lastRecordFile)
		if err != nil {
			return files, err
		}
		lastFile = strings.TrimSpace(lastFile)

		fileList, err = p.getFileList(path)
		if err != nil {
			return files, err
		}

		if newFileList, err = p.getNewFile(lastFile, fileList); err != nil {
			return files, err
		}

		if len(newFileList) <= 0 {
			continue
		}

		// write last file
		for _, newFile := range newFileList {
			err = common.WriteFile(lastRecordFile, newFile)
			if err != nil {
				return files, err
			}
			files = append(files, []byte(path+"/"+newFile))
		}
	}
	return files, nil
}
Esempio n. 2
0
//监听到容器消亡时做的操作
func Die(client *docker.Client, event *docker.APIEvents) {
	fmt.Println("Received die event %s for container %s", event.Status, event.ID[:12])
	container, err := client.InspectContainer(event.ID[:12])
	common.ErrorHandle(err)
	include := common.GetConfig("Section", "include")
	if include == "*" || strings.Contains(","+include+",", ","+common.SubstrAfter(container.Name, 0)+",") {
		strData := common.ReadFile(common.GetConfig("Section", "hostFile"))
		arrData := strings.Split(strData, "\n")
		strData = ""
		for i := 0; i < len(arrData); i++ {
			if strings.Index(arrData[i], getDomainName(container.Name)) >= 0 {
				continue
			}
			if strData == "" {
				strData = arrData[i]
			} else {
				strData += "\n" + arrData[i]
			}
		}
		common.SaveFile(common.GetConfig("Section", "hostFile"), strData)
		restartDns()
	}
}
Esempio n. 3
0
func (this *Upload) Get() {
	conf := common.ReadFile("conf/ueditor.json")
	this.Ctx.WriteString(conf)
}