-
Notifications
You must be signed in to change notification settings - Fork 48
/
main.go
45 lines (37 loc) · 1.16 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
package main
import (
"math/rand"
"net/http"
"time"
"github.com/lbryio/lbrytv/apps/lbrytv/config"
"github.com/lbryio/lbrytv/cmd"
"github.com/lbryio/lbrytv/internal/monitor"
"github.com/lbryio/lbrytv/internal/reflection"
"github.com/lbryio/lbrytv/internal/storage"
"github.com/lbryio/lbrytv/version"
)
func main() {
rand.Seed(time.Now().UnixNano())
// this is a *client-side* timeout (for when we make http requests, not when we serve them)
//https://blog.cloudflare.com/the-complete-guide-to-golang-net-http-timeouts/
http.DefaultClient.Timeout = 20 * time.Second
dbConfig := config.GetDatabase()
monitor.IsProduction = config.IsProduction()
monitor.ConfigureSentry(config.GetSentryDSN(), version.GetDevVersion(), monitor.LogMode())
conn := storage.InitConn(storage.ConnParams{
Connection: dbConfig.Connection,
DBName: dbConfig.DBName,
Options: dbConfig.Options,
})
err := conn.Connect()
if err != nil {
panic(err)
}
defer conn.Close()
conn.SetDefaultConnection()
go conn.WatchMetrics(10 * time.Second)
rMgr := reflection.NewManager("/nonexistent", config.GetReflectorAddress())
rMgr.Initialize()
rMgr.Start(time.Minute * 1)
cmd.Execute()
}