add race delay for existing connections during startup
This commit is contained in:
parent
785d314cd1
commit
a61dcc3cb0
@ -110,6 +110,7 @@ func NewNTFServer(configFile string, verbose bool) (*NTFServer, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Spawn upstream connections for all pre-existing known users
|
// Spawn upstream connections for all pre-existing known users
|
||||||
|
launchedAny := false
|
||||||
for telegramUserId, telegramDisplayName := range ret.config.GroupChatMembers {
|
for telegramUserId, telegramDisplayName := range ret.config.GroupChatMembers {
|
||||||
hubNick, ok := ret.config.KnownUsers[telegramUserId]
|
hubNick, ok := ret.config.KnownUsers[telegramUserId]
|
||||||
if !ok {
|
if !ok {
|
||||||
@ -120,6 +121,14 @@ func NewNTFServer(configFile string, verbose bool) (*NTFServer, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, fmt.Errorf("Reconnecting upstream for '%s': %s", hubNick, err.Error()) // fatal
|
return nil, fmt.Errorf("Reconnecting upstream for '%s': %s", hubNick, err.Error()) // fatal
|
||||||
}
|
}
|
||||||
|
|
||||||
|
launchedAny = true
|
||||||
|
}
|
||||||
|
|
||||||
|
// We have some bad edge cases if a telegram message comes in while the upstream
|
||||||
|
// connection is offline. Wait a bit after startup, to minimise failure cases
|
||||||
|
if launchedAny {
|
||||||
|
time.Sleep(5 * time.Second)
|
||||||
}
|
}
|
||||||
|
|
||||||
return &ret, nil
|
return &ret, nil
|
||||||
|
Loading…
Reference in New Issue
Block a user