Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitaly.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJacob Vosmaer (GitLab) <jacob@gitlab.com>2017-12-15 18:16:23 +0300
committerAhmad Sherif <ahmad.m.sherif@gmail.com>2017-12-15 18:16:23 +0300
commit832f32e14702fa513fdb0b8b25785287d034f85c (patch)
tree9bd26fbcd300f1360a47458869962cc09a595275 /internal/command
parentfd572dbc74f7386da09848f4bb393905d75d49f7 (diff)
Eagerly close logrus writer pipes
Diffstat (limited to 'internal/command')
-rw-r--r--internal/command/command.go17
1 files changed, 12 insertions, 5 deletions
diff --git a/internal/command/command.go b/internal/command/command.go
index 2d53d6ef0..a80adca02 100644
--- a/internal/command/command.go
+++ b/internal/command/command.go
@@ -39,10 +39,11 @@ var exportedEnvVars = []string{
// terminated and reaped automatically when the context.Context that
// created it is canceled.
type Command struct {
- reader io.Reader
- cmd *exec.Cmd
- context context.Context
- startTime time.Time
+ reader io.Reader
+ logrusWriter io.WriteCloser
+ cmd *exec.Cmd
+ context context.Context
+ startTime time.Time
waitError error
waitOnce sync.Once
@@ -150,7 +151,8 @@ func New(ctx context.Context, cmd *exec.Cmd, stdin io.Reader, stdout, stderr io.
cmd.Stderr = stderr
} else {
// If we don't do something with cmd.Stderr, Git errors will be lost
- cmd.Stderr = grpc_logrus.Extract(ctx).WriterLevel(log.InfoLevel)
+ command.logrusWriter = grpc_logrus.Extract(ctx).WriterLevel(log.InfoLevel)
+ cmd.Stderr = command.logrusWriter
}
if err := cmd.Start(); err != nil {
@@ -203,6 +205,11 @@ func (c *Command) wait() {
}
c.logProcessComplete(c.context, exitCode)
+
+ if w := c.logrusWriter; w != nil {
+ // Closing this writer lets a logrus goroutine finish early
+ w.Close()
+ }
}
// ExitStatus will return the exit-code from an error returned by Wait().