forked from shawn1m/overture
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
57 lines (45 loc) · 1.26 KB
/
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
53
54
55
56
57
// Copyright (c) 2016 shawn1m. All rights reserved.
// Use of this source code is governed by The MIT License (MIT) that can be
// found in the LICENSE file.
// Package main is the entry point of whole program.
package main
import (
"flag"
"io"
"os"
"runtime"
log "github.com/Sirupsen/logrus"
"github.com/wheelerlaw/octodns/core"
)
// For auto version building
// go build -ldflags "-X main.version=version"
var version string
func main() {
var (
configPath string
logPath string
isLogVerbose bool
processorNumber int
)
flag.StringVar(&configPath, "c", "./config.json", "config file path")
flag.StringVar(&logPath, "l", "", "log file path")
flag.BoolVar(&isLogVerbose, "v", false, "verbose mode")
flag.IntVar(&processorNumber, "p", runtime.NumCPU(), "number of processor to use")
flag.Parse()
if isLogVerbose {
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(log.InfoLevel)
}
if logPath != "" {
lf, err := os.OpenFile(logPath, os.O_APPEND|os.O_WRONLY|os.O_CREATE, 0640)
if err != nil {
println("Logfile error: Please check your log file path")
} else {
log.SetOutput(io.MultiWriter(lf, os.Stdout))
}
}
log.Info("octodns is starting" + version)
runtime.GOMAXPROCS(processorNumber)
core.InitServer(configPath)
}