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:
authorPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-18 09:49:02 +0300
committerPatrick Steinhardt <psteinhardt@gitlab.com>2022-05-18 10:06:20 +0300
commit32474ae99c506421a9f681c704a35e63b47c8d2b (patch)
treee924662e221901f69b226beb7a22688260219b20
parentab0e402a9e910d99b13ef3f1631844d5fa386c97 (diff)
supervisor: Avoid spawning two Goroutines for logging purposes
We use different loggers for both stdout and stderr of processes spawned by our supervisor. And while these loggers aren't any different, this means that we now also have two Goroutines copying the process's output into the loggers. Let's improve this and only use a single Goroutine by reusing the same log writer for both streams.
-rw-r--r--internal/supervisor/supervisor.go7
1 files changed, 5 insertions, 2 deletions
diff --git a/internal/supervisor/supervisor.go b/internal/supervisor/supervisor.go
index f695b071e..0c7310817 100644
--- a/internal/supervisor/supervisor.go
+++ b/internal/supervisor/supervisor.go
@@ -93,11 +93,14 @@ func New(config Config, name string, env []string, args []string, dir string, me
func (p *Process) start(logger *log.Entry) (*exec.Cmd, error) {
startCounter.WithLabelValues(p.Name).Inc()
+ logWriter := logger.WriterLevel(log.InfoLevel)
+
cmd := exec.Command(p.args[0], p.args[1:]...)
cmd.Env = p.env
cmd.Dir = p.dir
- cmd.Stdout = logger.WriterLevel(log.InfoLevel)
- cmd.Stderr = logger.WriterLevel(log.InfoLevel)
+ cmd.Stdout = logWriter
+ cmd.Stderr = logWriter
+
return cmd, cmd.Start()
}