forked from sourcegraph/sourcegraph-public-snapshot
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
44 lines (38 loc) · 1.22 KB
/
main.go
File metadata and controls
44 lines (38 loc) · 1.22 KB
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
// The monitoring generator is now called by Bazel targets instead of go generate
//
// To run monitoring generator run:
// - bazel build //monitoring:generate_config # see bazel-bin/monitoring/outputs
// - bazel build //monitoring:generate_config_zip # see bazel-bin/monitoring/monitoring.zip
// - bazel build //monitoring:generate_grafana_config_tar # see bazel-bin/monitoring/monitoring.tar
package main
import (
"os"
"github.com/sourcegraph/log"
"github.com/urfave/cli/v2"
"github.com/sourcegraph/sourcegraph/monitoring/command"
)
func main() {
// Configure logger
if _, set := os.LookupEnv(log.EnvDevelopment); !set {
os.Setenv(log.EnvDevelopment, "true")
}
if _, set := os.LookupEnv(log.EnvLogFormat); !set {
os.Setenv(log.EnvLogFormat, "console")
}
liblog := log.Init(log.Resource{Name: "monitoring-generator"})
defer liblog.Sync()
logger := log.Scoped("monitoring")
// Create an app that only runs the generate command
app := &cli.App{
Name: "monitoring-generator",
Commands: []*cli.Command{
command.Generate("", "../"),
},
DefaultCommand: "generate",
}
if err := app.Run(os.Args); err != nil {
// Render in plain text for human readability
println(err.Error())
logger.Fatal("error encountered")
}
}