| OLD | NEW |
| 1 // Copyright 2015 The LUCI Authors. All rights reserved. | 1 // Copyright 2015 The LUCI Authors. All rights reserved. |
| 2 // Use of this source code is governed under the Apache License, Version 2.0 | 2 // Use of this source code is governed under the Apache License, Version 2.0 |
| 3 // that can be found in the LICENSE file. | 3 // that can be found in the LICENSE file. |
| 4 | 4 |
| 5 package main | 5 package main |
| 6 | 6 |
| 7 import ( | 7 import ( |
| 8 "bytes" | 8 "bytes" |
| 9 "flag" | 9 "flag" |
| 10 "fmt" | 10 "fmt" |
| 11 "net/http" | 11 "net/http" |
| 12 "os" | 12 "os" |
| 13 "os/signal" | 13 "os/signal" |
| 14 "sort" | 14 "sort" |
| 15 "strings" | 15 "strings" |
| 16 "time" | 16 "time" |
| 17 | 17 |
| 18 "github.com/maruel/subcommands" | 18 "github.com/maruel/subcommands" |
| 19 "golang.org/x/net/context" | 19 "golang.org/x/net/context" |
| 20 | 20 |
| 21 "github.com/luci/luci-go/client/authcli" | 21 "github.com/luci/luci-go/client/authcli" |
| 22 "github.com/luci/luci-go/common/auth" | 22 "github.com/luci/luci-go/common/auth" |
| 23 "github.com/luci/luci-go/common/cli" | 23 "github.com/luci/luci-go/common/cli" |
| 24 "github.com/luci/luci-go/common/clock/clockflag" | 24 "github.com/luci/luci-go/common/clock/clockflag" |
| 25 "github.com/luci/luci-go/common/config" | |
| 26 "github.com/luci/luci-go/common/errors" | 25 "github.com/luci/luci-go/common/errors" |
| 27 "github.com/luci/luci-go/common/flag/multiflag" | 26 "github.com/luci/luci-go/common/flag/multiflag" |
| 28 log "github.com/luci/luci-go/common/logging" | 27 log "github.com/luci/luci-go/common/logging" |
| 29 "github.com/luci/luci-go/common/logging/gologger" | 28 "github.com/luci/luci-go/common/logging/gologger" |
| 30 "github.com/luci/luci-go/common/runtime/paniccatcher" | 29 "github.com/luci/luci-go/common/runtime/paniccatcher" |
| 31 "github.com/luci/luci-go/common/runtime/profiling" | 30 "github.com/luci/luci-go/common/runtime/profiling" |
| 32 grpcLogging "github.com/luci/luci-go/grpc/logging" | 31 grpcLogging "github.com/luci/luci-go/grpc/logging" |
| 33 "github.com/luci/luci-go/logdog/client/butler" | 32 "github.com/luci/luci-go/logdog/client/butler" |
| 34 "github.com/luci/luci-go/logdog/client/butler/output" | 33 "github.com/luci/luci-go/logdog/client/butler/output" |
| 35 "github.com/luci/luci-go/logdog/client/butlerlib/streamproto" | 34 "github.com/luci/luci-go/logdog/client/butlerlib/streamproto" |
| 36 "github.com/luci/luci-go/logdog/common/types" | 35 "github.com/luci/luci-go/logdog/common/types" |
| 36 "github.com/luci/luci-go/luci_config/common/cfgtypes" |
| 37 ) | 37 ) |
| 38 | 38 |
| 39 const ( | 39 const ( |
| 40 // flagErrorReturnCode is returned when there is an error with the Butle
r's | 40 // flagErrorReturnCode is returned when there is an error with the Butle
r's |
| 41 // command-line configuration. | 41 // command-line configuration. |
| 42 configErrorReturnCode = 2 | 42 configErrorReturnCode = 2 |
| 43 | 43 |
| 44 // runtimeErrorReturnCode is returned when the execution fails due to a
Butler | 44 // runtimeErrorReturnCode is returned when the execution fails due to a
Butler |
| 45 // error. This is intended to help differentiate Butler errors from | 45 // error. This is intended to help differentiate Butler errors from |
| 46 // passthrough bootstrapped subprocess errors. | 46 // passthrough bootstrapped subprocess errors. |
| 47 // | 47 // |
| 48 // This will only be returned for runtime errors. If there is a flag err
or | 48 // This will only be returned for runtime errors. If there is a flag err
or |
| 49 // or a configuration error, standard Butler return codes (likely to ove
rlap | 49 // or a configuration error, standard Butler return codes (likely to ove
rlap |
| 50 // with standard process return codes) will be used. | 50 // with standard process return codes) will be used. |
| 51 runtimeErrorReturnCode = 250 | 51 runtimeErrorReturnCode = 250 |
| 52 ) | 52 ) |
| 53 | 53 |
| 54 // application is the Butler application instance and its runtime configuration | 54 // application is the Butler application instance and its runtime configuration |
| 55 // and state. | 55 // and state. |
| 56 type application struct { | 56 type application struct { |
| 57 cli.Application | 57 cli.Application |
| 58 context.Context | 58 context.Context |
| 59 | 59 |
| 60 » project config.ProjectName | 60 » project cfgtypes.ProjectName |
| 61 prefix types.StreamName | 61 prefix types.StreamName |
| 62 coordinatorHost string | 62 coordinatorHost string |
| 63 outputWorkers int | 63 outputWorkers int |
| 64 outputConfig outputConfigFlag | 64 outputConfig outputConfigFlag |
| 65 ioKeepAliveInterval clockflag.Duration | 65 ioKeepAliveInterval clockflag.Duration |
| 66 | 66 |
| 67 authFlags authcli.Flags | 67 authFlags authcli.Flags |
| 68 | 68 |
| 69 globalTags streamproto.TagMap | 69 globalTags streamproto.TagMap |
| 70 maxBufferAge clockflag.Duration | 70 maxBufferAge clockflag.Duration |
| (...skipping 278 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 349 | 349 |
| 350 paniccatcher.Do(func() { | 350 paniccatcher.Do(func() { |
| 351 rc = mainImpl(ctx, os.Args[1:]) | 351 rc = mainImpl(ctx, os.Args[1:]) |
| 352 }, func(p *paniccatcher.Panic) { | 352 }, func(p *paniccatcher.Panic) { |
| 353 log.Fields{ | 353 log.Fields{ |
| 354 "panic.error": p.Reason, | 354 "panic.error": p.Reason, |
| 355 }.Errorf(ctx, "Panic caught in main:\n%s", p.Stack) | 355 }.Errorf(ctx, "Panic caught in main:\n%s", p.Stack) |
| 356 rc = runtimeErrorReturnCode | 356 rc = runtimeErrorReturnCode |
| 357 }) | 357 }) |
| 358 } | 358 } |
| OLD | NEW |