Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(195)

Side by Side Diff: server/internal/logdog/service/service.go

Issue 1863973002: LogDog: Update to archival V2. (Closed) Base URL: https://github.com/luci/luci-go@grpcutil-errors
Patch Set: Fix proto comment. Created 4 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
« no previous file with comments | « server/internal/logdog/collector/collector.go ('k') | server/logdog/archive/archive.go » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2016 The Chromium Authors. All rights reserved. 1 // Copyright 2016 The Chromium Authors. All rights reserved.
2 // Use of this source code is governed by a BSD-style license that can be 2 // Use of this source code is governed by a BSD-style license that can be
3 // found in the LICENSE file. 3 // found in the LICENSE file.
4 4
5 package service 5 package service
6 6
7 import ( 7 import (
8 "errors" 8 "errors"
9 "flag" 9 "flag"
10 "net/http" 10 "net/http"
(...skipping 38 matching lines...) Expand 10 before | Expand all | Expand 10 after
49 shutdownFunc atomic.Value 49 shutdownFunc atomic.Value
50 50
51 loggingFlags log.Config 51 loggingFlags log.Config
52 authFlags authcli.Flags 52 authFlags authcli.Flags
53 configFlags config.Flags 53 configFlags config.Flags
54 54
55 coordinatorHost string 55 coordinatorHost string
56 coordinatorInsecure bool 56 coordinatorInsecure bool
57 storageCredentialJSONPath string 57 storageCredentialJSONPath string
58 cpuProfilePath string 58 cpuProfilePath string
59 heapProfilePath string
59 60
60 coord logdog.ServicesClient 61 coord logdog.ServicesClient
61 config *config.Manager 62 config *config.Manager
62 } 63 }
63 64
64 // Run performs service-wide initialization and invokes the specified run 65 // Run performs service-wide initialization and invokes the specified run
65 // function. 66 // function.
66 func (s *Service) Run(c context.Context, f func(context.Context) error) { 67 func (s *Service) Run(c context.Context, f func(context.Context) error) {
67 c = gologger.Use(c) 68 c = gologger.Use(c)
68 69
(...skipping 23 matching lines...) Expand all
92 "path": p, 93 "path": p,
93 }.Errorf(c, "Failed to create CPU profile output file.") 94 }.Errorf(c, "Failed to create CPU profile output file.")
94 return err 95 return err
95 } 96 }
96 defer fd.Close() 97 defer fd.Close()
97 98
98 pprof.StartCPUProfile(fd) 99 pprof.StartCPUProfile(fd)
99 defer pprof.StopCPUProfile() 100 defer pprof.StopCPUProfile()
100 } 101 }
101 102
103 if p := s.heapProfilePath; p != "" {
104 defer func() {
105 fd, err := os.Create(p)
106 if err != nil {
107 log.Fields{
108 log.ErrorKey: err,
109 "path": p,
110 }.Warningf(c, "Failed to create heap profile out put file.")
111 return
112 }
113 defer fd.Close()
114
115 if err := pprof.WriteHeapProfile(fd); err != nil {
116 log.Fields{
117 log.ErrorKey: err,
118 "path": p,
119 }.Warningf(c, "Failed to write heap profile.")
120 }
121 }()
122 }
123
102 // Configure our signal handler. It will listen for terminating signals and 124 // Configure our signal handler. It will listen for terminating signals and
103 // issue a shutdown signal if one is received. 125 // issue a shutdown signal if one is received.
104 signalC := make(chan os.Signal) 126 signalC := make(chan os.Signal)
105 go func() { 127 go func() {
106 hasShutdownAlready := false 128 hasShutdownAlready := false
107 for sig := range signalC { 129 for sig := range signalC {
108 if !hasShutdownAlready { 130 if !hasShutdownAlready {
109 hasShutdownAlready = true 131 hasShutdownAlready = true
110 132
111 log.Warningf(log.SetField(c, "signal", sig), "Re ceived close signal. Send again to terminate immediately.") 133 log.Warningf(log.SetField(c, "signal", sig), "Re ceived close signal. Send again to terminate immediately.")
(...skipping 42 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 s.configFlags.AddToFlagSet(fs) 176 s.configFlags.AddToFlagSet(fs)
155 177
156 fs.StringVar(&s.coordinatorHost, "coordinator", "", 178 fs.StringVar(&s.coordinatorHost, "coordinator", "",
157 "The Coordinator service's [host][:port].") 179 "The Coordinator service's [host][:port].")
158 fs.BoolVar(&s.coordinatorInsecure, "coordinator-insecure", false, 180 fs.BoolVar(&s.coordinatorInsecure, "coordinator-insecure", false,
159 "Connect to Coordinator over HTTP (instead of HTTPS).") 181 "Connect to Coordinator over HTTP (instead of HTTPS).")
160 fs.StringVar(&s.storageCredentialJSONPath, "storage-credential-json-path ", "", 182 fs.StringVar(&s.storageCredentialJSONPath, "storage-credential-json-path ", "",
161 "If supplied, the path of a JSON credential file to load and use for storage operations.") 183 "If supplied, the path of a JSON credential file to load and use for storage operations.")
162 fs.StringVar(&s.cpuProfilePath, "cpu-profile-path", "", 184 fs.StringVar(&s.cpuProfilePath, "cpu-profile-path", "",
163 "If supplied, enable CPU profiling and write the profile here.") 185 "If supplied, enable CPU profiling and write the profile here.")
186 fs.StringVar(&s.heapProfilePath, "heap-profile-path", "",
187 "If supplied, enable CPU profiling and write the profile here.")
164 } 188 }
165 189
166 func (s *Service) initCoordinatorClient(c context.Context) (logdog.ServicesClien t, error) { 190 func (s *Service) initCoordinatorClient(c context.Context) (logdog.ServicesClien t, error) {
167 if s.coordinatorHost == "" { 191 if s.coordinatorHost == "" {
168 log.Errorf(c, "Missing Coordinator URL (-coordinator).") 192 log.Errorf(c, "Missing Coordinator URL (-coordinator).")
169 return nil, ErrInvalidConfig 193 return nil, ErrInvalidConfig
170 } 194 }
171 195
172 httpClient, err := s.AuthenticatedClient(func(o *auth.Options) { 196 httpClient, err := s.AuthenticatedClient(func(o *auth.Options) {
173 o.Scopes = CoordinatorScopes 197 o.Scopes = CoordinatorScopes
(...skipping 157 matching lines...) Expand 10 before | Expand all | Expand 10 after
331 // 355 //
332 // An optional permutation functon can be provided to modify those Options 356 // An optional permutation functon can be provided to modify those Options
333 // before the Authenticator is created. 357 // before the Authenticator is created.
334 func (s *Service) AuthenticatedClient(f func(o *auth.Options)) (*http.Client, er ror) { 358 func (s *Service) AuthenticatedClient(f func(o *auth.Options)) (*http.Client, er ror) {
335 a, err := s.Authenticator(f) 359 a, err := s.Authenticator(f)
336 if err != nil { 360 if err != nil {
337 return nil, err 361 return nil, err
338 } 362 }
339 return a.Client() 363 return a.Client()
340 } 364 }
OLDNEW
« no previous file with comments | « server/internal/logdog/collector/collector.go ('k') | server/logdog/archive/archive.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698