diff options
author | Kirill <g4s8.public@gmail.com> | 2021-08-25 16:50:54 +0300 |
---|---|---|
committer | Toon Claes <toon@gitlab.com> | 2021-08-26 13:09:24 +0300 |
commit | dcffcc4967033ba819a3d131096ea60bfb503618 (patch) | |
tree | dced7348bf7b68a00d88dd99f7271a9206c7dadb /cmd | |
parent | 32b44d3c44af62f55c1049743149c103dfd58fb7 (diff) |
FindLicense: Implement license finding in Go
This change implements the license finding in Go using
github.com/go-enry/go-license-detector.
Issue: https://gitlab.com/gitlab-org/gitaly/-/issues/3078
Changelog: performance
Diffstat (limited to 'cmd')
-rw-r--r-- | cmd/gitaly/main.go | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/cmd/gitaly/main.go b/cmd/gitaly/main.go index 4304ee970..f9f5baa02 100644 --- a/cmd/gitaly/main.go +++ b/cmd/gitaly/main.go @@ -7,6 +7,7 @@ import ( "os" "time" + "github.com/go-enry/go-license-detector/v4/licensedb" "github.com/prometheus/client_golang/prometheus" log "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/gitaly/v14/client" @@ -110,6 +111,7 @@ func configure(configPath string) (config.Cfg, error) { cfg.Prometheus.Configure() config.ConfigureConcurrencyLimits(cfg) tracing.Initialize(tracing.WithServiceName("gitaly")) + preloadLicenseDatabase() return cfg, nil } @@ -129,6 +131,16 @@ func verifyGitVersion(cfg config.Cfg) error { return nil } +func preloadLicenseDatabase() { + // the first call to `licensedb.Detect` could be too long + // https://github.com/go-enry/go-license-detector/issues/13 + // this is why we're calling it here to preload license database + // on server startup to avoid long initialization on gRPC + // method handling. + licensedb.Preload() + log.Info("License database preloaded") +} + func run(cfg config.Cfg) error { ctx, cancel := context.WithCancel(context.Background()) defer cancel() |