-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.go
47 lines (39 loc) · 871 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
package main
import (
"database/sql"
log "github.com/sirupsen/logrus"
"recordgram/bot"
"recordgram/config"
"recordgram/controller"
"recordgram/db"
logging2 "recordgram/logging"
"sync"
"time"
)
var start = time.Now()
func main() {
logging2.Init()
loadedConfig := config.FromFile()
database := db.SetupDB(loadedConfig)
sqlDb, _ := database.DB()
defer func(sqlDb *sql.DB) {
err := sqlDb.Close()
if err != nil {
log.WithError(err).Infof("DB: close")
}
}(sqlDb)
telegramBot := bot.SetupBot(loadedConfig, database)
server := controller.NewServer(loadedConfig, database, telegramBot)
var waitGroup sync.WaitGroup
waitGroup.Add(2)
go func() {
defer waitGroup.Done()
telegramBot.Start(loadedConfig)
}()
go func() {
defer waitGroup.Done()
server.Start()
}()
log.Infof("Startup took aprox %v", time.Since(start))
waitGroup.Wait()
}