mirror of
https://github.com/minio/minio.git
synced 2024-12-24 22:25:54 -05:00
Print goroutines when shutdown hangs (#8574)
This commit is contained in:
parent
b21835f195
commit
db3dbcce3a
@ -19,7 +19,9 @@ package http
|
|||||||
import (
|
import (
|
||||||
"crypto/tls"
|
"crypto/tls"
|
||||||
"errors"
|
"errors"
|
||||||
|
"io/ioutil"
|
||||||
"net/http"
|
"net/http"
|
||||||
|
"runtime/pprof"
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
@ -137,6 +139,13 @@ func (srv *Server) Shutdown() error {
|
|||||||
for {
|
for {
|
||||||
select {
|
select {
|
||||||
case <-shutdownTimer.C:
|
case <-shutdownTimer.C:
|
||||||
|
// Write all running goroutines.
|
||||||
|
tmp, err := ioutil.TempFile("", "minio-goroutines-*.txt")
|
||||||
|
if err == nil {
|
||||||
|
_ = pprof.Lookup("goroutine").WriteTo(tmp, 1)
|
||||||
|
tmp.Close()
|
||||||
|
return errors.New("timed out. some connections are still active. doing abnormal shutdown. goroutines written to " + tmp.Name())
|
||||||
|
}
|
||||||
return errors.New("timed out. some connections are still active. doing abnormal shutdown")
|
return errors.New("timed out. some connections are still active. doing abnormal shutdown")
|
||||||
case <-ticker.C:
|
case <-ticker.C:
|
||||||
if atomic.LoadInt32(&srv.requestCount) <= 0 {
|
if atomic.LoadInt32(&srv.requestCount) <= 0 {
|
||||||
|
Loading…
Reference in New Issue
Block a user