.
This commit is contained in:
		
							parent
							
								
									19afde84eb
								
							
						
					
					
						commit
						b9730776ab
					
				@ -56,6 +56,12 @@ func (c *configManager) getContainerPath() string {
 | 
			
		||||
	return c.getConfigPath() + "container/"
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
func (c *configManager) getConfigFilePath(config *config_manager.Config) string {
 | 
			
		||||
	return c.getContainerPath() + appendSeperator(config.Crawler.Container) + appendSeperator(config.Crawler.Name) + config.Id
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
func appendSeperator(str string) string {
 | 
			
		||||
	if strings.LastIndex(str, "/") != len(str)-1 {
 | 
			
		||||
		return str + "/"
 | 
			
		||||
@ -100,6 +106,8 @@ func (c *configManager) loadCrawlerConfig(root string, dir string) {
 | 
			
		||||
	}
 | 
			
		||||
 | 
			
		||||
	for _, file := range files {
 | 
			
		||||
		
 | 
			
		||||
		// 디렉터리라면 재귀 / 파일이라면 설정 로드
 | 
			
		||||
		if file.IsDir() == true {
 | 
			
		||||
			c.loadCrawlerConfig(currentDir, file.Name())
 | 
			
		||||
		} else {
 | 
			
		||||
@ -135,7 +143,7 @@ func (c *configManager) addConfig() {
 | 
			
		||||
 | 
			
		||||
		// agent 폴더 / config / crawler / .. / .. / .. / 에 해당하는 파일이 있는지 확인, 있다면 삭제
 | 
			
		||||
		// Config 파일로 저장
 | 
			
		||||
		savePath := c.getContainerPath() + appendSeperator(m.Crawler.Container) + appendSeperator(m.Crawler.Name) + m.Id
 | 
			
		||||
		savePath := c.getConfigFilePath(&m)
 | 
			
		||||
		ioutil.WriteFile(savePath, b, 0644)
 | 
			
		||||
 | 
			
		||||
		// tempfile remove
 | 
			
		||||
@ -167,7 +175,7 @@ func (c *configManager) removeConfig() {
 | 
			
		||||
		}
 | 
			
		||||
 | 
			
		||||
		// 해당 파일 삭제
 | 
			
		||||
		path := c.getContainerPath() + appendSeperator(config.Crawler.Container) + appendSeperator(config.Crawler.Name) + config.Id
 | 
			
		||||
		path := c.getConfigFilePath(config)
 | 
			
		||||
		err := os.Remove(path)
 | 
			
		||||
		if err != nil {
 | 
			
		||||
			// error check
 | 
			
		||||
 | 
			
		||||
@ -1,5 +1,3 @@
 | 
			
		||||
 | 
			
		||||
// +build !test
 | 
			
		||||
package config_manager_go
 | 
			
		||||
 | 
			
		||||
import (
 | 
			
		||||
@ -34,7 +32,7 @@ func TestLoadConfig(t *testing.T) {
 | 
			
		||||
	
 | 
			
		||||
	assert.NotEqual(t, len(c.configs),0)
 | 
			
		||||
	observer.Notify(messages.CONFIGMANAGER_LOADED,c)
 | 
			
		||||
	time.Sleep(2 * time.Second)
 | 
			
		||||
	time.Sleep(1 * time.Second)
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user