reworked 'tail' function for subordinate access (#789)

This commit is contained in:
Michael Quigley 2024-11-12 13:04:21 -05:00
parent 94cfba746c
commit f5601e3a54
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62

View File

@ -46,24 +46,37 @@ func (a *access) tail(data []byte) {
if line, err := a.readBuffer.ReadString('\n'); err == nil { if line, err := a.readBuffer.ReadString('\n'); err == nil {
line = strings.Trim(line, "\n") line = strings.Trim(line, "\n")
if !a.booted { if !a.booted {
in := make(map[string]interface{}) if strings.HasPrefix(line, "{") {
if err := json.Unmarshal([]byte(line), &in); err == nil { in := make(map[string]interface{})
if v, found := in["frontend_token"]; found { if err := json.Unmarshal([]byte(line), &in); err == nil {
if str, ok := v.(string); ok { if v, found := in["message"]; found {
a.frontendToken = str if str, ok := v.(string); ok {
if str == "boot" {
if v, found := in["frontend_token"]; found {
if str, ok := v.(string); ok {
a.frontendToken = str
}
}
if v, found := in["bind_address"]; found {
if str, ok := v.(string); ok {
a.bindAddress = str
}
}
a.booted = true
}
} else {
a.bootErr = errors.New(line)
}
} else {
logrus.Warn(line)
} }
} else {
a.bootErr = errors.New(line)
} }
if v, found := in["bind_address"]; found { close(a.bootComplete)
if str, ok := v.(string); ok {
a.bindAddress = str
}
}
a.booted = true
} else { } else {
a.bootErr = errors.New(line) logrus.Warn(line)
} }
close(a.bootComplete)
} else { } else {
if strings.HasPrefix(line, "{") { if strings.HasPrefix(line, "{") {
in := make(map[string]interface{}) in := make(map[string]interface{})