-
Notifications
You must be signed in to change notification settings - Fork 12
/
main.go
40 lines (32 loc) · 801 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
package main
import (
"log"
"github.com/benalexau/ibconnect/core"
"github.com/benalexau/ibconnect/gateway"
"github.com/benalexau/ibconnect/server"
)
func main() {
c, err := core.NewConfig()
if err != nil {
log.Fatal(err)
}
ctx, err := core.NewContext(c)
if err != nil {
log.Fatal(err)
}
defer ctx.Close()
ffs := gateway.FeedFactories(c)
gatewayController, err := gateway.NewGatewayController(ffs, ctx.DB, ctx.N, ctx.DL, c.IbGws, c.IbClientId)
if err != nil {
log.Fatal(err)
}
defer gatewayController.Close()
terminated := handleSignals()
handler := server.Handler(c.ErrInfo, ctx.DB, ctx.N)
err = server.Serve(terminated, c.Address(), handler)
if err != nil {
log.Fatal(err)
}
// ensure we have terminated (useful if HTTP server commented out etc)
<-terminated
}