-
Notifications
You must be signed in to change notification settings - Fork 8
/
main.go
51 lines (41 loc) · 1022 Bytes
/
main.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
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package main
import (
"fmt"
"log"
"os"
"time"
)
var Running = true
func main() {
log.Println("Git Notes is starting...")
var git = NewGoGit()
var watcher = GitWatcher{
git: &git,
running: false,
checkInterval: 10 * time.Second,
delayBeforeFiringEvent: 2 * time.Second,
delayAfterFiringEvent: 5 * time.Second,
}
var configReader = JsonConfigReader{}
var gitRepoMonitor = GitRepoMonitor{
scheduledUpdateInterval: 5 * time.Minute,
}
Run(&git, &watcher, &configReader, &gitRepoMonitor)
for Running {
time.Sleep(1 * time.Second)
}
}
func Run(git Git, watcher Watcher, configReader ConfigReader, monitor PathMonitor) {
if len(os.Args) < 2 {
log.Fatal("Please pass the config file path as the first argument.")
}
configPath := os.Args[1]
config, err := configReader.Read(configPath)
if err != nil {
log.Fatalf("Unable to read the config file. Err: %v", err)
}
fmt.Println(config)
for _, repoPath := range config.Repos {
monitor.StartMonitoring(repoPath, watcher, git)
}
}