-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmain.go
63 lines (51 loc) · 1.23 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
58
59
60
61
62
63
// -*- Go -*-
/* ------------------------------------------------ */
/* Golang source */
/* Author: Alexei Panov <me@elemc.name> */
/* ------------------------------------------------ */
package main
import (
"flag"
"sync"
log "github.com/sirupsen/logrus"
)
var (
configName string
wg sync.WaitGroup
)
func init() {
flag.StringVar(&configName, "config", "gotelegrambot", "configuration file name")
}
func main() {
var err error
flag.Parse()
if err = LoadConfig(); err != nil {
log.Fatalf("Unable to load configuration file %s: %s", configName, err)
}
if level, err := log.ParseLevel(options.LogLevel); err != nil {
log.Warnf("Unable to parse log level %s: %s", options.LogLevel, err)
log.SetLevel(log.DebugLevel)
} else {
log.SetLevel(level)
}
log.Warnf("Application started...")
if err = InitDatabase(); err != nil {
log.Fatalf("Unable to connect to database: %s", err)
}
go cacheUpdate()
wg.Add(1)
go func() {
if err = botServe(); err != nil {
log.Errorf("Unable to serve bot: %s", err)
}
}()
wg.Add(1)
go func() {
if err = httpServe(); err != nil {
log.Errorf("Unable to serve HTTP server: %s", err)
}
}()
wg.Add(1)
go updateFeeds()
wg.Wait()
}