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

Function main

cmd/async-gateway/main.go:41–120  ·  view source on GitHub ↗

usage: ./gateway -bucket -region -port

()

Source from the content-addressed store, hash-verified

39
40// usage: ./gateway -bucket <bucket> -region <region> -port <port>
41func main() {
42 log := logging.GetLogger()
43 defer func() {
44 _ = log.Sync()
45 }()
46
47 var (
48 bucket = flag.String("bucket", "", "bucket")
49 clusterUID = flag.String("cluster-uid", "", "cluster uid")
50 port = flag.String("port", _defaultPort, "port on which the gateway server runs on")
51 )
52 flag.Parse()
53
54 switch {
55 case *bucket == "":
56 log.Fatal("missing required option: -bucket")
57 case *clusterUID == "":
58 log.Fatal("missing required option: -cluster-uid")
59 }
60
61 awsClient, err := aws.New()
62 if err != nil {
63 exit(log, err)
64 }
65
66 _, userID, err := awsClient.CheckCredentials()
67 if err != nil {
68 exit(log, err)
69 }
70
71 telemetryEnabled := strings.ToLower(os.Getenv("CORTEX_TELEMETRY_DISABLE")) != "true"
72 err = telemetry.Init(telemetry.Config{
73 Enabled: telemetryEnabled,
74 UserID: userID,
75 Properties: map[string]string{
76 "kind": userconfig.AsyncAPIKind.String(),
77 "image_type": "async-gateway",
78 },
79 Environment: "api",
80 LogErrors: true,
81 BackoffMode: telemetry.BackoffDuplicateMessages,
82 })
83 if err != nil {
84 log.Fatalw("failed to initialize telemetry", zap.Error(err))
85 }
86 defer telemetry.Close()
87
88 sess := awsClient.Session()
89 s3Storage := gateway.NewS3(sess, *bucket)
90
91 svc := gateway.NewService(*clusterUID, s3Storage, log, *sess)
92 ep := gateway.NewEndpoint(svc, log)
93
94 router := mux.NewRouter()
95 router.HandleFunc("/", ep.CreateWorkload).Methods("POST")
96 router.HandleFunc(
97 "/healthz",
98 func(w http.ResponseWriter, r *http.Request) {

Callers

nothing calls this directly

Calls 11

GetLoggerFunction · 0.92
NewFunction · 0.92
InitFunction · 0.92
CloseFunction · 0.92
CheckCredentialsMethod · 0.80
ErrorMethod · 0.80
SessionMethod · 0.80
SetMethod · 0.80
WriteMethod · 0.80
exitFunction · 0.70
StringMethod · 0.45

Tested by

no test coverage detected