-
Notifications
You must be signed in to change notification settings - Fork 0
/
fwatcher.go
31 lines (27 loc) · 729 Bytes
/
fwatcher.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
package main
import (
"os"
log "github.com/sirupsen/logrus"
"github.com/asccclass/filewatch/libs/filemonitor"
)
func main() {
dir, err := os.Getwd()
if err != nil {
log.Printf("Initial error:%v.", err)
}
documentRoot := os.Getenv("DocumentRoot")
if documentRoot == "" {
documentRoot = "www"
}
documentRoot = dir + "/" + documentRoot
nightswatch, err := filemonitor.NewMonitor(documentRoot, "")
if err != nil {
log.Println(err)
return
}
log.Println("Night gathers, and now my watch begins,It shall not end until my death....")
log.Printf("I'm watching %v....", documentRoot)
nightswatch.Do()
nightswatch.FileWatcher.Watch(documentRoot)
select {}
}