-
Notifications
You must be signed in to change notification settings - Fork 13
/
sctplb.go
61 lines (52 loc) · 1.45 KB
/
sctplb.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
// SPDX-FileCopyrightText: 2022 Open Networking Foundation <[email protected]>
//
// SPDX-License-Identifier: Apache-2.0
package main
import (
"os"
"path/filepath"
"github.com/omec-project/sctplb/backend"
"github.com/omec-project/sctplb/config"
"github.com/omec-project/sctplb/logger"
"github.com/urfave/cli/v2"
)
func main() {
app := cli.NewApp()
app.Name = "sctplb"
logger.AppLog.Infoln(app.Name)
app.Usage = "SCTP Load Balancer"
app.UsageText = "sctplb -cfg <sctplb_config_file.conf>"
app.Flags = []cli.Flag{
&cli.StringFlag{
Name: "cfg",
Usage: "sctplb config file",
Required: true,
},
}
app.Action = action
if err := app.Run(os.Args); err != nil {
logger.AppLog.Fatalf("SCTPLB run error: %v", err)
}
}
func action(c *cli.Context) error {
logger.AppLog.Infoln("sctp-lb started")
cfg := c.String("cfg")
absPath, err := filepath.Abs(cfg)
if err != nil {
logger.CfgLog.Errorln(err)
return err
}
sctplbConfig, err := config.InitConfigFactory(absPath)
if err != nil {
logger.AppLog.Errorf("failed to initialize config: %v", err)
return err
}
// Read messages from SCTP Sockets and push it on channel
logger.AppLog.Infof("sctp port: %d grpc port: %d", sctplbConfig.Configuration.NgapPort, sctplbConfig.Configuration.SctpGrpcPort)
backend.ServiceRun(sctplbConfig.Configuration.NgapIpList, sctplbConfig.Configuration.NgapPort)
b := backend.BackendSvc{
Cfg: sctplbConfig,
}
b.DispatchAddServer()
return nil
}