MCPcopy
hub / github.com/cortexlabs/cortex / main

Function main

cmd/proxy/main.go:46–189  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

44)
45
46func main() {
47 var (
48 port int
49 adminPort int
50 userContainerPort int
51 maxConcurrency int
52 maxQueueLength int
53 hasTCPProbe bool
54 clusterConfigPath string
55 )
56
57 flag.IntVar(&port, "port", 8000, "port where the proxy server will be exposed")
58 flag.IntVar(&adminPort, "admin-port", 15000, "port where the admin server (for metrics and probes) will be exposed")
59 flag.IntVar(&userContainerPort, "user-port", 8080, "port where the proxy will redirect to the traffic to")
60 flag.IntVar(&maxConcurrency, "max-concurrency", 0, "max concurrency allowed for user container")
61 flag.IntVar(&maxQueueLength, "max-queue-length", 0, "max request queue length for user container")
62 flag.BoolVar(&hasTCPProbe, "has-tcp-probe", false, "tcp probe to the user-provided container port")
63 flag.StringVar(&clusterConfigPath, "cluster-config", "", "cluster config path")
64 flag.Parse()
65
66 log := logging.GetLogger()
67 defer func() {
68 _ = log.Sync()
69 }()
70
71 switch {
72 case maxConcurrency == 0:
73 log.Fatal("--max-concurrency flag is required")
74 case maxQueueLength == 0:
75 log.Fatal("--max-queue-length flag is required")
76 case clusterConfigPath == "":
77 log.Fatal("--cluster-config flag is required")
78 }
79
80 clusterConfig, err := clusterconfig.NewForFile(clusterConfigPath)
81 if err != nil {
82 exit(log, err)
83 }
84
85 awsClient, err := aws.NewForRegion(clusterConfig.Region)
86 if err != nil {
87 exit(log, err)
88 }
89
90 _, userID, err := awsClient.CheckCredentials()
91 if err != nil {
92 exit(log, err)
93 }
94
95 err = telemetry.Init(telemetry.Config{
96 Enabled: clusterConfig.Telemetry,
97 UserID: userID,
98 Properties: map[string]string{
99 "kind": userconfig.RealtimeAPIKind.String(),
100 "image_type": "proxy",
101 },
102 Environment: "api",
103 LogErrors: true,

Callers

nothing calls this directly

Calls 15

ReportMethod · 0.95
ReportMethod · 0.95
AppendMethod · 0.95
InFlightMethod · 0.95
GetLoggerFunction · 0.92
NewForFileFunction · 0.92
NewForRegionFunction · 0.92
InitFunction · 0.92
CloseFunction · 0.92
NewReverseProxyFunction · 0.92
NewBreakerFunction · 0.92

Tested by

no test coverage detected