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

Unified Diff: client/cmd/logdog_butler/subcommand_run.go

Issue 1975683002: LogDog: Implement prefix registration in Butler. (Closed) Base URL: https://github.com/luci/luci-go@logdog-butler-register-collector
Patch Set: Rebarse Created 4 years, 7 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « client/cmd/logdog_butler/output_pubsub.go ('k') | client/cmd/logdog_butler/subcommand_serve.go » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: client/cmd/logdog_butler/subcommand_run.go
diff --git a/client/cmd/logdog_butler/subcommand_run.go b/client/cmd/logdog_butler/subcommand_run.go
index 354edcb42d6243c8d860d20bbaa1f03567e17bdf..bb3f69fb6e3471b6e3748be20e089a52b64f6f8d 100644
--- a/client/cmd/logdog_butler/subcommand_run.go
+++ b/client/cmd/logdog_butler/subcommand_run.go
@@ -181,6 +181,16 @@ func (cmd *runCommandRun) Run(app subcommands.Application, args []string) int {
}()
}
+ // We're about ready to execute our command. Initialize our Output instance.
+ // We want to do this before we execute our subprocess so that if this fails,
+ // we don't have to interrupt an already-running process.
+ output, err := a.configOutput()
+ if err != nil {
+ log.WithError(err).Errorf(a, "Failed to create output instance.")
+ return runtimeErrorReturnCode
+ }
+ defer output.Close()
+
// Construct and execute the command
proc := ctxcmd.CtxCmd{
Cmd: exec.Command(commandPath, args...),
@@ -276,7 +286,7 @@ func (cmd *runCommandRun) Run(app subcommands.Application, args []string) int {
}.Infof(ctx, "Process completed.")
}()
- err = a.Main(func(b *butler.Butler) error {
+ err = a.runWithButler(output, func(b *butler.Butler) error {
// We will execute the bootstrapped command, then the Butler. Since we are
// hooking the Butler up to the command, the Butler's execution will be
// bounded by the availability of the command's STDOUT/STDERR streams. If
@@ -345,8 +355,8 @@ func (cmd *runCommandRun) loadJSONArgs() ([]string, error) {
// updateEnvironment adds common Butler bootstrapping environment variables
// to the environment.
func (cmd *runCommandRun) updateEnvironment(e environ, a *application) {
- e.set(bootstrap.EnvStreamPrefix, string(a.butler.Prefix))
- e.set(bootstrap.EnvStreamProject, string(a.butler.Project))
+ e.set(bootstrap.EnvStreamPrefix, string(a.prefix))
+ e.set(bootstrap.EnvStreamProject, string(a.project))
// Set stream server path (if applicable)
if cmd.streamServerURI != "" {
« no previous file with comments | « client/cmd/logdog_butler/output_pubsub.go ('k') | client/cmd/logdog_butler/subcommand_serve.go » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698