func()

in src/log/config_watcher.go [46:74]


func (fileWatcher *FileWatcher) Start() {

	fileWatcher.log.Debugf("Start File Watcher On: %v", fileWatcher.configFilePath)

	// Since the filewatcher fails if the file does not exist, need to watch the parent directory for any changes
	dirPath := filepath.Dir(fileWatcher.configFilePath)
	fileWatcher.log.Debugf("Start Watcher on directory: %v", dirPath)

	// Creating Watcher
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		// Error initializing the watcher
		fileWatcher.log.Errorf("Error initializing the watcher: %v", err)
		return
	}

	fileWatcher.watcher = watcher

	// Starting the goroutine for event handler
	go fileWatcher.fileEventHandler()

	// Add the directory to watcher
	err = fileWatcher.watcher.Add(dirPath)
	if err != nil {
		// Error adding the file to watcher
		fileWatcher.log.Errorf("Error adding the directory to watcher: %v", err)
		return
	}
}