mirror of
https://github.com/kemko/nomad.git
synced 2026-01-06 10:25:42 +03:00
fix deadlock issue, switch to frames envelope
This commit is contained in:
@@ -105,9 +105,6 @@ func (d *Monitor) Start(stopCh <-chan struct{}) <-chan []byte {
|
||||
// Write attempts to send latest log to logCh
|
||||
// it drops the log if channel is unavailable to receive
|
||||
func (d *Monitor) Write(p []byte) (n int, err error) {
|
||||
d.Lock()
|
||||
defer d.Unlock()
|
||||
|
||||
bytes := make([]byte, len(p))
|
||||
copy(bytes, p)
|
||||
|
||||
|
||||
@@ -89,7 +89,7 @@ func (c *MonitorCommand) Run(args []string) int {
|
||||
Params: params,
|
||||
}
|
||||
eventDoneCh := make(chan struct{})
|
||||
logCh, err := client.Agent().Monitor(eventDoneCh, query)
|
||||
frames, err := client.Agent().Monitor(eventDoneCh, query)
|
||||
if err != nil {
|
||||
c.Ui.Error(fmt.Sprintf("Error starting monitor: %s", err))
|
||||
c.Ui.Error(commandErrorText(c))
|
||||
@@ -101,11 +101,11 @@ func (c *MonitorCommand) Run(args []string) int {
|
||||
OUTER:
|
||||
for {
|
||||
select {
|
||||
case log, ok := <-logCh:
|
||||
case frame, ok := <-frames:
|
||||
if !ok {
|
||||
break OUTER
|
||||
}
|
||||
c.Ui.Output(log)
|
||||
c.Ui.Output(string(frame.Data))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user