-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathmain.go
52 lines (40 loc) · 869 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
51
52
package main
import (
"os"
"os/signal"
"syscall"
"github.com/ivpusic/golog"
)
var (
logger = golog.GetLogger("github.com/ivpusic/rerun")
TEST_MODE = false
)
func main() {
conf, err := loadConfiguration()
if err != nil {
logger.Panicf("Error while loading configuration! %s", err.Error())
}
// setup logger level
if *verbose {
logger.Level = golog.DEBUG
} else {
logger.Level = golog.INFO
}
pm := &processManager{
conf: conf,
}
w := &watcher{pm: pm}
sigs := make(chan os.Signal)
signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM)
// on ctrl+c remove build files
go func(conf *config) {
<-sigs
logger.Debug("Cleanup build files generated by rerun...")
err := os.Remove(conf.build)
if err != nil && !os.IsNotExist(err) {
logger.Warnf("Build file not removed! %s", err.Error())
}
os.Exit(0)
}(conf)
w.start()
}