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

add flags for internal time constants

parent 6980206a
Branches
Tags
No related merge requests found
...@@ -3,6 +3,7 @@ package node ...@@ -3,6 +3,7 @@ package node
import ( import (
"bytes" "bytes"
"encoding/json" "encoding/json"
"flag"
"log" "log"
"net" "net"
"os" "os"
...@@ -18,6 +19,9 @@ import ( ...@@ -18,6 +19,9 @@ import (
) )
var ( var (
masterElectionTtl = flag.Int("master-election-ttl", 5, "TTL for the master election protocol (s)")
nodeHeartbeat = flag.Int("heartbeat", 3, "Period for the node presence heartbeat (s)")
icecastReloadErrors = instrumentation.NewCounter("icecast.reload_errors") icecastReloadErrors = instrumentation.NewCounter("icecast.reload_errors")
icecastReloads = instrumentation.NewCounter("icecast.reload") icecastReloads = instrumentation.NewCounter("icecast.reload")
configIndex = instrumentation.NewGauge("config.etcd_index") configIndex = instrumentation.NewGauge("config.etcd_index")
...@@ -280,12 +284,12 @@ func NewRadioNode(name string, ips []net.IP, netDev string, bwLimit float64, cli ...@@ -280,12 +284,12 @@ func NewRadioNode(name string, ips []net.IP, netDev string, bwLimit float64, cli
client, client,
autoradio.MasterElectionPath, autoradio.MasterElectionPath,
string(minfodata), string(minfodata),
5, uint64(*masterElectionTtl),
mech), mech),
watcher: newConfigSyncer(client, config, upch), watcher: newConfigSyncer(client, config, upch),
icecast: NewIcecastController(name), icecast: NewIcecastController(name),
reloadDelay: 1000 * time.Millisecond, reloadDelay: 1000 * time.Millisecond,
heartbeat: 2, heartbeat: uint64(*nodeHeartbeat),
bw: bwmonitor.NewBandwidthUsageMonitor(netDev, bwLimit), bw: bwmonitor.NewBandwidthUsageMonitor(netDev, bwLimit),
upch: upch, upch: upch,
stop: stopch, stop: stopch,
...@@ -318,7 +322,7 @@ func (rc *RadioNode) presence(stop chan bool) { ...@@ -318,7 +322,7 @@ func (rc *RadioNode) presence(stop chan bool) {
var buf bytes.Buffer var buf bytes.Buffer
json.NewEncoder(&buf).Encode(&nodeStatus) json.NewEncoder(&buf).Encode(&nodeStatus)
if _, err := rc.client.Set(key, buf.String(), rc.heartbeat); err != nil { if _, err := rc.client.Set(key, buf.String(), rc.heartbeat); err != nil {
rc.Log.Printf("presence: Set(): %s", err) rc.Log.Printf("presence: Set(): %v", err)
} }
case <-stop: case <-stop:
...@@ -359,7 +363,7 @@ func (rc *RadioNode) updater(stop chan bool) { ...@@ -359,7 +363,7 @@ func (rc *RadioNode) updater(stop chan bool) {
rc.Log.Printf("reloading icecast config") rc.Log.Printf("reloading icecast config")
if err := rc.icecast.Update(rc.config, rc.me.IsMaster(), rc.getMasterAddr()); err != nil { if err := rc.icecast.Update(rc.config, rc.me.IsMaster(), rc.getMasterAddr()); err != nil {
icecastReloadErrors.Incr() icecastReloadErrors.Incr()
rc.Log.Printf("Update(): %s", err) rc.Log.Printf("Update(): %v", err)
} }
// Limit the rate of icecast reloads. // Limit the rate of icecast reloads.
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment