diff options
Diffstat (limited to 'src/rhctl')
-rw-r--r-- | src/rhctl/playout_server.go | 33 |
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 } |