1
0
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:
Jeromy
2015-10-29 21:26:12 -07:00
parent 94bdce63a7
commit 2f5563b3c0
20 changed files with 23 additions and 710 deletions

View File

@ -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)
},
}