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

Function main

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

Source from the content-addressed store, hash-verified

43)
44
45func main() {
46 var (
47 port int
48 adminPort int
49 inCluster bool
50 autoscalerURL string
51 namespace string
52 )
53
54 flag.IntVar(&port, "port", 8000, "port where the activator server will be exposed")
55 flag.IntVar(&adminPort, "admin-port", 15000, "port where the admin server will be exposed")
56 flag.BoolVar(&inCluster, "in-cluster", false, "use when autoscaler runs in-cluster")
57 flag.StringVar(&autoscalerURL, "autoscaler-url", "", "the URL for the cortex autoscaler endpoint")
58 flag.StringVar(&namespace, "namespace", os.Getenv("CORTEX_NAMESPACE"),
59 "kubernetes namespace where the cortex APIs are deployed "+
60 "(can be set through the CORTEX_NAMESPACE env variable)",
61 )
62 flag.Parse()
63
64 log := logging.GetLogger()
65 defer func() {
66 _ = log.Sync()
67 }()
68
69 switch {
70 case autoscalerURL == "":
71 log.Fatal("--autoscaler-url is a required option")
72 case namespace == "":
73 log.Fatal("--namespace is a required option")
74 }
75
76 awsClient, err := aws.New()
77 if err != nil {
78 exit(log, err)
79 }
80
81 _, userID, err := awsClient.CheckCredentials()
82 if err != nil {
83 exit(log, err)
84 }
85
86 telemetryEnabled := strings.ToLower(os.Getenv("CORTEX_TELEMETRY_DISABLE")) != "true"
87
88 err = telemetry.Init(telemetry.Config{
89 Enabled: telemetryEnabled,
90 UserID: userID,
91 Properties: map[string]string{
92 "kind": userconfig.RealtimeAPIKind.String(),
93 "image_type": "activator",
94 },
95 Environment: "operator",
96 LogErrors: true,
97 BackoffMode: telemetry.BackoffDuplicateMessages,
98 })
99 if err != nil {
100 log.Fatalw("failed to initialize telemetry", zap.Error(err))
101 }
102 defer telemetry.Close()

Callers

nothing calls this directly

Calls 15

GetLoggerFunction · 0.92
NewFunction · 0.92
InitFunction · 0.92
CloseFunction · 0.92
NewFunction · 0.92
NewClientFunction · 0.92
NewFunction · 0.92
NewHandlerFunction · 0.92
ErrorFunction · 0.92
WrapFunction · 0.92
CheckCredentialsMethod · 0.80

Tested by

no test coverage detected