@@ -46,7 +46,6 @@ func main() {
4646 client := etcd .NewClient ([]string {"http://" + publishHost + ":" + publishPort })
4747
4848 signalChan := make (chan os.Signal , 1 )
49- drainRespChan := make (chan * etcd.Response )
5049 drainChan := make (chan string )
5150 stopChan := make (chan bool )
5251 exitChan := make (chan bool )
@@ -58,18 +57,31 @@ func main() {
5857 setEtcd (client , publishPath + "/drain" , drainURI , 0 )
5958 }
6059
61- go client .Watch (publishPath + "/drain" , 0 , false , drainRespChan , stopChan )
6260 go syslogd .Listen (exitChan , cleanupChan , drainChan , fmt .Sprintf ("%s:%d" , logAddr , logPort ))
6361 if enablePublish {
6462 go publishService (exitChan , client , publishHost , publishPath , strconv .Itoa (logPort ), uint64 (time .Duration (publishTTL ).Seconds ()))
6563 }
6664
65+ // HACK (bacongobbler): poll etcd for changes in the log drain value
66+ // etcd's .Watch() implementation is broken when you use TTLs
67+ //
68+ // https://github.com/coreos/etcd/issues/2679
69+ go func () {
70+ for {
71+ resp , err := client .Get (publishPath + "/drain" , false , false )
72+ if err != nil {
73+ log .Printf ("warning: could not retrieve drain URI from etcd: %v\n " , err )
74+ continue
75+ }
76+ if resp != nil && resp .Node != nil {
77+ drainChan <- resp .Node .Value
78+ }
79+ time .Sleep (time .Duration (publishInterval ))
80+ }
81+ }()
82+
6783 for {
6884 select {
69- case dr := <- drainRespChan :
70- if dr != nil && dr .Node != nil {
71- drainChan <- dr .Node .Value
72- }
7385 case <- signalChan :
7486 close (exitChan )
7587 stopChan <- true
0 commit comments