// TODO: This is pretty horrible...
This is pretty horrible
// TODO : This is pretty horrible ...
func WatchFileChange() {
	server := Global()
	watcher, err := fsnotify.NewWatcher()
	if err != nil {
		log.Fatal("FileWatcher", err)
	}
	auth := server.Auth
	filepath := auth.GetFilepath()
	watcher.Add(filepath)
	for {
		select {
		case event, ok := <-watcher.Events:
			if !ok {
				log.Fatal("File Watcher Failed", errors.New("FileWatcher"))
			}
			if event.Op&fsnotify.Write == fsnotify.Write {
				auth.Reload()
				TryWebServerRestart()
			}
		case err, ok := <-watcher.Errors:
			if !ok {
				log.Fatal("File Watcher Errors Failed", errors.New("FileWatcher"))
			}
			fmt.Println("File Watcher", err.(error).Error())
			return
		}
	}
}
func WatchFileChange ( ) { server := Global ( ) watcher , err := fsnotify . NewWatcher ( ) if err != nil { log . Fatal ( " " , err ) } auth := server . Auth filepath := auth . GetFilepath ( ) watcher . Add ( filepath ) for { select { case event , ok := <- watcher . Events : if ! ok { log . Fatal ( " " , errors . New ( " " ) ) } if event . Op & fsnotify . Write == fsnotify . Write { auth . Reload ( ) TryWebServerRestart ( ) } case err , ok := <- watcher . Errors : if ! ok { log . Fatal ( " " , errors . New ( " " ) ) } fmt . Println ( " " , err . ( error ) . Error ( ) ) return } } }
This is pretty horrible
This is pretty horrible
// Createa new watcher // Watch the accounts file to see if anyone has registered // If the file is modified, reload it // TODO: Sometimes Causes the web server to die // TODO: Seems to have bad fd errors sometimes? Sets it into an endless // error loop. Instead, we'll just stop it and no longer have the // ability to register properly.