Skip to content
Snippets Groups Projects
Commit 7e551437 authored by ale's avatar ale
Browse files

minor logging fixes

parent 353e1579
No related branches found
No related tags found
No related merge requests found
...@@ -110,7 +110,7 @@ func (ic *IcecastController) statusUpdater() { ...@@ -110,7 +110,7 @@ func (ic *IcecastController) statusUpdater() {
ic.status = status ic.status = status
icecastOk.Set(1) icecastOk.Set(1)
} else { } else {
log.Printf("bad status from iceast: %v", err) log.Printf("error checking iceast status: %v", err)
ic.status = downStatus ic.status = downStatus
icecastOk.Set(0) icecastOk.Set(0)
} }
......
...@@ -104,6 +104,17 @@ func (w *ConfigSyncer) setIndex(index uint64) { ...@@ -104,6 +104,17 @@ func (w *ConfigSyncer) setIndex(index uint64) {
configIndex.Set(int64(index)) configIndex.Set(int64(index))
} }
func (w *ConfigSyncer) updateConfigWithResponse(index uint64, key, value string) {
mountName := keyToMount(key)
log.Printf("updating mount %s [@%d]: %s", mountName, index, value)
var m autoradio.Mount
if err := json.NewDecoder(strings.NewReader(value)).Decode(&m); err != nil {
log.Printf("corrupted data: %s: %s", value, err)
} else {
w.config.setMount(&m)
}
}
func (w *ConfigSyncer) syncer(ch chan *etcd.Response) { func (w *ConfigSyncer) syncer(ch chan *etcd.Response) {
for { for {
select { select {
...@@ -124,7 +135,7 @@ func (w *ConfigSyncer) syncer(ch chan *etcd.Response) { ...@@ -124,7 +135,7 @@ func (w *ConfigSyncer) syncer(ch chan *etcd.Response) {
log.Printf("deleted mount %s", mountName) log.Printf("deleted mount %s", mountName)
w.config.delMount(mountName) w.config.delMount(mountName)
} else if response.Action == "set" || response.Action == "create" || response.Action == "update" { } else if response.Action == "set" || response.Action == "create" || response.Action == "update" {
w.updateConfigWithResponse(response.Node.Key, response.Node.Value) w.updateConfigWithResponse(response.EtcdIndex, response.Node.Key, response.Node.Value)
} else { } else {
continue continue
} }
...@@ -138,17 +149,6 @@ func (w *ConfigSyncer) syncer(ch chan *etcd.Response) { ...@@ -138,17 +149,6 @@ func (w *ConfigSyncer) syncer(ch chan *etcd.Response) {
} }
} }
func (w *ConfigSyncer) updateConfigWithResponse(key, value string) {
mountName := keyToMount(key)
log.Printf("updating mount %s: %s", mountName, value)
var m autoradio.Mount
if err := json.NewDecoder(strings.NewReader(value)).Decode(&m); err != nil {
log.Printf("corrupted data: %s: %s", value, err)
} else {
w.config.setMount(&m)
}
}
// Load full configuration from etcd. This will trigger the update channel. // Load full configuration from etcd. This will trigger the update channel.
func (w *ConfigSyncer) loadFullConfig() { func (w *ConfigSyncer) loadFullConfig() {
for { for {
...@@ -156,8 +156,9 @@ func (w *ConfigSyncer) loadFullConfig() { ...@@ -156,8 +156,9 @@ func (w *ConfigSyncer) loadFullConfig() {
if err == nil && response.Node != nil && response.Node.Dir { if err == nil && response.Node != nil && response.Node.Dir {
// Directly update the configuration. // Directly update the configuration.
for _, n := range response.Node.Nodes { for _, n := range response.Node.Nodes {
w.updateConfigWithResponse(n.Key, n.Value) w.updateConfigWithResponse(response.EtcdIndex, n.Key, n.Value)
} }
log.Printf("got configuration at index %d", response.EtcdIndex)
w.setIndex(response.EtcdIndex) w.setIndex(response.EtcdIndex)
break break
} }
...@@ -172,7 +173,6 @@ func (w *ConfigSyncer) loadFullConfig() { ...@@ -172,7 +173,6 @@ func (w *ConfigSyncer) loadFullConfig() {
} }
// Update the icecast daemon now that we have a full config. // Update the icecast daemon now that we have a full config.
log.Printf("triggering initial reload")
trigger(w.upch) trigger(w.upch)
} }
...@@ -181,13 +181,12 @@ func (w *ConfigSyncer) loadFullConfig() { ...@@ -181,13 +181,12 @@ func (w *ConfigSyncer) loadFullConfig() {
// in-memory configuration has already been fully synchronized. // in-memory configuration has already been fully synchronized.
func (w *ConfigSyncer) Start() { func (w *ConfigSyncer) Start() {
// Run until the first successful Get(). // Run until the first successful Get().
log.Printf("attempting to retrieve initial config") log.Printf("retrieving initial config")
w.loadFullConfig() w.loadFullConfig()
// Main watch loop. Remember that etcd.Watch() will close the // Main watch loop. Remember that etcd.Watch() will close the
// receiver channel when it returns, so we need to start a new // receiver channel when it returns, so we need to start a new
// syncer every time. // syncer every time.
log.Printf("starting config syncer")
go func() { go func() {
for { for {
ch := make(chan *etcd.Response) ch := make(chan *etcd.Response)
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment