golang.org/x/build@v0.0.0-20240506185731-218518f32b70/perf/main.go (about) 1 // Copyright 2022 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 // perf runs an HTTP server for benchmark analysis. 6 package main 7 8 import ( 9 "context" 10 "flag" 11 "log" 12 "net/http" 13 "os" 14 15 "golang.org/x/build/internal/https" 16 "golang.org/x/build/perf/app" 17 "golang.org/x/build/perfdata" 18 ) 19 20 var ( 21 perfdataURL = flag.String("perfdata", "https://perfdata.golang.org", "perfdata server base `url`") 22 influxHost = flag.String("influx-host", os.Getenv("INFLUX_HOST"), "URL of the InfluxDB instance") 23 influxToken = flag.String("influx-token", os.Getenv("INFLUX_TOKEN"), "Authentication token for the InfluxDB instance") 24 influxProject = flag.String("influx-project", os.Getenv("INFLUX_PROJECT"), "GCP project ID for the InfluxDB instance. If empty, defaults to the project this service is running as. If -influx-token is not set, the token is fetched from Secret Manager in the project.") 25 authCronEmail = flag.String("auth-cron-email", "", "If set, requests to /cron/syncinflux must be authenticated as the passed service account.") 26 ) 27 28 func main() { 29 https.RegisterFlags(flag.CommandLine) 30 flag.Parse() 31 32 app := &app.App{ 33 StorageClient: &perfdata.Client{BaseURL: *perfdataURL}, 34 InfluxHost: *influxHost, 35 InfluxToken: *influxToken, 36 InfluxProject: *influxProject, 37 AuthCronEmail: *authCronEmail, 38 } 39 mux := http.NewServeMux() 40 app.RegisterOnMux(mux) 41 42 log.Printf("Serving...") 43 44 ctx := context.Background() 45 log.Fatal(https.ListenAndServe(ctx, mux)) 46 }