mirror of
https://github.com/ipfs/kubo.git
synced 2025-06-19 18:05:32 +08:00
fix log hanging issue, and implement close-notify for commands
License: MIT Signed-off-by: Jeromy <jeromyj@gmail.com>
This commit is contained in:
@ -77,12 +77,13 @@ var logTailCmd = &cmds.Command{
|
||||
},
|
||||
|
||||
Run: func(req cmds.Request, res cmds.Response) {
|
||||
ctx := req.Context()
|
||||
r, w := io.Pipe()
|
||||
logging.WriterGroup.AddWriter(w)
|
||||
go func() {
|
||||
<-req.Context().Done()
|
||||
w.Close()
|
||||
defer w.Close()
|
||||
<-ctx.Done()
|
||||
}()
|
||||
logging.WriterGroup.AddWriter(w)
|
||||
res.SetOutput(r)
|
||||
},
|
||||
}
|
||||
|
Reference in New Issue
Block a user