summaryrefslogtreecommitdiff
path: root/src/rhctl
diff options
context:
space:
mode:
authorChristian Pointner <equinox@spreadspace.org>2016-03-27 19:20:55 (GMT)
committerChristian Pointner <equinox@spreadspace.org>2016-03-27 19:20:55 (GMT)
commitfef133ba130d6d78b58ce0b42b351b06e89d6a82 (patch)
tree1c5d5737faafdd5d6421b9aae8d08078a42c666d /src/rhctl
parent2e2b6ea6a2267fa9c95d3b74c7cb9dd00531a915 (diff)
added channel to request server status updates
Diffstat (limited to 'src/rhctl')
-rw-r--r--src/rhctl/playout_server.go33
1 files changed, 22 insertions, 11 deletions
diff --git a/src/rhctl/playout_server.go b/src/rhctl/playout_server.go
index 96e6fb7..bc31019 100644
--- a/src/rhctl/playout_server.go
+++ b/src/rhctl/playout_server.go
@@ -50,15 +50,16 @@ type ServerStatus struct {
}
type PlayoutServer struct {
- name string
- control *SerialPort
- heartbeat *SerialPort
- hbtimeout time.Duration
- hbtimer *time.Timer
- hbthreshold uint
- hbcnt uint
- status ServerStatus
- Updates chan ServerStatus
+ name string
+ control *SerialPort
+ heartbeat *SerialPort
+ hbtimeout time.Duration
+ hbtimer *time.Timer
+ hbthreshold uint
+ hbcnt uint
+ status ServerStatus
+ Updates chan ServerStatus
+ UpdateRequest chan bool
}
func (srv *PlayoutServer) handleControl(data string) {
@@ -89,6 +90,9 @@ func (srv *PlayoutServer) handleHeartbeat(data string) {
if old != srv.status.Health {
srv.Updates <- srv.status
rhl.Printf("Server(%s): is back from the dead!", srv.name)
+ if srv.status.Channel == "" {
+ srv.control.tx <- "channel ?"
+ }
}
}
@@ -117,6 +121,12 @@ func (srv *PlayoutServer) Run() {
srv.handleHeartbeat(data)
case <-srv.hbtimer.C:
srv.handleHBTimeout()
+ case <-srv.UpdateRequest:
+ if srv.status.Health == ServerDead {
+ srv.Updates <- srv.status
+ } else {
+ srv.control.tx <- "channel ?"
+ }
}
}
}
@@ -135,12 +145,13 @@ func ServerInit(name string, conf *Config) (srv *PlayoutServer, err error) {
srv.status.Health = ServerDead
srv.status.Channel = ""
srv.Updates = make(chan ServerStatus, 8)
+ srv.UpdateRequest = make(chan bool, 8)
- if srv.control, err = SerialOpen(conf.Servers[name].ControlDevice, conf.Servers[name].ControlBaudrate, "\r\n"); err != nil {
+ if srv.control, err = SerialOpen(conf.Servers[name].ControlDevice, conf.Servers[name].ControlBaudrate, "\n"); err != nil {
err = fmt.Errorf("Server(%s): error opening control port: %s", srv.name, err)
return
}
- if srv.heartbeat, err = SerialOpen(conf.Servers[name].HeartbeatDevice, conf.Servers[name].HeartbeatBaudrate, "\r\n"); err != nil {
+ if srv.heartbeat, err = SerialOpen(conf.Servers[name].HeartbeatDevice, conf.Servers[name].HeartbeatBaudrate, "\n"); err != nil {
err = fmt.Errorf("Server(%s): error opening heartbeat port: %s", srv.name, err)
return
}