-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
51 lines (40 loc) · 966 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
package main
import (
"io"
"os"
"tiberious/handlers/connection"
"tiberious/settings"
"github.com/Sirupsen/logrus"
)
func main() {
log := logrus.New()
// Errors or warnings encountered when initializing settings will always
// print to stdout because we don't know if there's a log file set in the
// config yet.
note, err := settings.Init(false)
if err != nil {
log.Println(err)
}
log.Println(note)
config := settings.GetConfig()
// At this point we have our config so set the log location in logrus (if
// found in config).
if config.Log != "" {
var writer io.Writer
writer, err = os.OpenFile(config.Log, os.O_RDWR|os.O_CREATE|os.O_APPEND, 0666)
if err != nil {
log.Fatal(err)
}
log.Out = writer
}
log.Level = logrus.DebugLevel
connectionHandler, err := connection.NewHandler(config, log)
if err != nil {
log.Fatal(err)
}
// TODO add shutdown/stop logic
connectionHandler.ListenAndServe()
for {
select {}
}
}