Merge pull request #4016 from influxdb/graphite_shutdown

Shutdown UDP Graphite on SIGTERM
pull/4021/head
Philip O'Toole 2015-09-05 08:49:13 -07:00
commit f0f254ae69
2 changed files with 11 additions and 6 deletions

View File

@ -33,6 +33,7 @@ With this release InfluxDB is moving to Go 1.5.
- [#3931](https://github.com/influxdb/influxdb/pull/3931): Don't precreate shard groups entirely in the past
- [#3960](https://github.com/influxdb/influxdb/issues/3960): possible "catch up" bug with nodes down in a cluster
- [#3980](https://github.com/influxdb/influxdb/pull/3980): 'service stop' waits until service actually stops. Fixes issue #3548.
- [#4016](https://github.com/influxdb/influxdb/pull/4016): Shutdown Graphite UDP on SIGTERM.
## v0.9.3 [2015-08-26]

View File

@ -96,8 +96,9 @@ type Service struct {
logger *log.Logger
statMap *expvar.Map
ln net.Listener
addr net.Addr
ln net.Listener
addr net.Addr
udpConn *net.UDPConn
wg sync.WaitGroup
done chan struct{}
@ -205,6 +206,9 @@ func (s *Service) Close() error {
if s.ln != nil {
s.ln.Close()
}
if s.udpConn != nil {
s.udpConn.Close()
}
s.batcher.Stop()
close(s.done)
@ -287,7 +291,7 @@ func (s *Service) openUDPServer() (net.Addr, error) {
return nil, err
}
conn, err := net.ListenUDP("udp", addr)
s.udpConn, err = net.ListenUDP("udp", addr)
if err != nil {
return nil, err
}
@ -297,9 +301,9 @@ func (s *Service) openUDPServer() (net.Addr, error) {
go func() {
defer s.wg.Done()
for {
n, _, err := conn.ReadFromUDP(buf)
n, _, err := s.udpConn.ReadFromUDP(buf)
if err != nil {
conn.Close()
s.udpConn.Close()
return
}
@ -311,7 +315,7 @@ func (s *Service) openUDPServer() (net.Addr, error) {
s.statMap.Add(statBytesReceived, int64(n))
}
}()
return conn.LocalAddr(), nil
return s.udpConn.LocalAddr(), nil
}
func (s *Service) handleLine(line string) {