Make sure instance does not exist before reconnecting
This commit is contained in:
@@ -126,6 +126,12 @@ func (m *manager) process() {
|
|||||||
t := m.terminals[i.name]
|
t := m.terminals[i.name]
|
||||||
t.write <- i.data
|
t.write <- i.data
|
||||||
case instance := <-m.errorCh:
|
case instance := <-m.errorCh:
|
||||||
|
// check if it still exists before reconnecting
|
||||||
|
i := core.InstanceGet(&types.Session{Id: instance.SessionId}, instance.Name)
|
||||||
|
if i == nil {
|
||||||
|
log.Println("Instance doest not exist anymore. Won't reconnect")
|
||||||
|
continue
|
||||||
|
}
|
||||||
log.Println("reconnecting")
|
log.Println("reconnecting")
|
||||||
m.connect(instance)
|
m.connect(instance)
|
||||||
}
|
}
|
||||||
@@ -177,11 +183,7 @@ func NewManager(s *types.Session) (*manager, error) {
|
|||||||
|
|
||||||
// There is a new instance in a session we are tracking. We should track it's terminal
|
// There is a new instance in a session we are tracking. We should track it's terminal
|
||||||
instanceName := args[0].(string)
|
instanceName := args[0].(string)
|
||||||
instance := core.InstanceGet(s, instanceName)
|
instance := &types.Instance{Name: instanceName}
|
||||||
if instance == nil {
|
|
||||||
log.Printf("Instance [%s] was not found in session [%s]\n", instanceName, sessionId)
|
|
||||||
return
|
|
||||||
}
|
|
||||||
m.disconnect(instance)
|
m.disconnect(instance)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user