-
-
Notifications
You must be signed in to change notification settings - Fork 7
/
Copy pathconfigure.go
66 lines (53 loc) · 1.38 KB
/
configure.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
64
65
66
package main
import (
log "github.com/sirupsen/logrus"
"github.com/urfave/cli"
cs "github.com/webtor-io/common-services"
s "github.com/webtor-io/content-transcoder/services"
)
func configure(app *cli.App) {
app.Flags = []cli.Flag{}
app.Flags = s.RegisterCommonFlags(app.Flags)
app.Flags = s.RegisterContentProberFlags(app.Flags)
app.Flags = s.RegisterWebFlags(app.Flags)
app.Flags = cs.RegisterProbeFlags(app.Flags)
app.Flags = cs.RegisterPprofFlags(app.Flags)
app.Flags = s.RegisterHLSFlags(app.Flags)
app.Action = run
}
func run(c *cli.Context) (err error) {
var servers []cs.Servable
// Setting ContentProbe
contentProbe := s.NewContentProbe(c)
// Setting Probe
probe := cs.NewProbe(c)
if probe != nil {
servers = append(servers, probe)
defer probe.Close()
}
// Setting Pprof
pprof := cs.NewPprof(c)
if pprof != nil {
servers = append(servers, pprof)
defer pprof.Close()
}
// Setting TranscodePool
transcodePool := s.NewTranscodePool()
// Setting TouchMap
touchMap := s.NewTouchMap()
// Setting HLSBuilder
hlsBuilder := s.NewHLSBuilder(c)
// Setting Web
web := s.NewWeb(c, contentProbe, hlsBuilder, transcodePool, touchMap)
servers = append(servers, web)
defer web.Close()
// Setting Serve
serve := cs.NewServe(servers...)
// And SERVE!
err = serve.Serve()
if err != nil {
log.WithError(err).Error("got server error")
return err
}
return err
}