Skip to content

Commit 4cf9cab

Browse files
committed
remove etcd dependency inside syslogd (TODO: squash this commit)
1 parent 124e427 commit 4cf9cab

2 files changed

Lines changed: 8 additions & 6 deletions

File tree

logger/main.go

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,8 @@ func main() {
4545
client := etcd.NewClient([]string{"http://" + publishHost + ":" + publishPort})
4646

4747
signalChan := make(chan os.Signal, 1)
48-
drainChan := make(chan *etcd.Response)
48+
drainRespChan := make(chan *etcd.Response)
49+
drainChan := make(chan string)
4950
stopChan := make(chan bool)
5051
exitChan := make(chan bool)
5152
cleanupChan := make(chan bool)
@@ -56,14 +57,16 @@ func main() {
5657
setEtcd(client, publishPath+"/drain", drainURI, 0)
5758
}
5859

59-
go client.Watch(publishPath+"/drain", 0, false, drainChan, stopChan)
60+
go client.Watch(publishPath+"/drain", 0, false, drainRespChan, stopChan)
6061
go syslogd.Listen(exitChan, cleanupChan, drainChan, fmt.Sprintf("%s:%d", logAddr, logPort))
6162
if enablePublish {
6263
go publishService(exitChan, client, publishHost, publishPath, strconv.Itoa(logPort), uint64(time.Duration(publishTTL).Seconds()))
6364
}
6465

6566
for {
6667
select {
68+
case er := <-drainRespChan:
69+
drainChan <- er.Node.Value
6770
case <-signalChan:
6871
close(exitChan)
6972
stopChan <- true

logger/syslogd/syslogd.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ import (
88
"path"
99
"regexp"
1010

11-
"github.com/coreos/go-etcd/etcd"
1211
"github.com/deis/deis/logger/syslog"
1312

1413
"github.com/deis/deis/logger/drain"
@@ -102,7 +101,7 @@ func (h *handler) mainLoop() {
102101
}
103102

104103
// Listen starts a new syslog server which runs until it receives a signal.
105-
func Listen(exitChan, cleanupDone chan bool, drainChan chan *etcd.Response, bindAddr string) {
104+
func Listen(exitChan, cleanupDone chan bool, drainChan chan string, bindAddr string) {
106105
fmt.Println("Starting syslog...")
107106
// If LogRoot doesn't exist, create it
108107
// equivalent to Python's `if not os.path.exists(filename)`
@@ -127,8 +126,8 @@ func Listen(exitChan, cleanupDone chan bool, drainChan chan *etcd.Response, bind
127126
fmt.Println("Shutting down...")
128127
s.Shutdown()
129128
cleanupDone <- true
130-
case er := <-drainChan:
131-
h.drainURI = er.Node.Value
129+
case d := <-drainChan:
130+
h.drainURI = d
132131
}
133132
}
134133
}

0 commit comments

Comments
 (0)