Common: Retry frontend connection for 4 seconds

This commit is contained in:
mkwcat 2024-05-08 22:13:13 -04:00
parent 8b9cbbac13
commit a949b5c727
No known key found for this signature in database
GPG Key ID: 7A505679CE9E7AA9

View File

@ -2,6 +2,7 @@ package common
import (
"net/rpc"
"time"
"wwfc/logging"
)
@ -16,9 +17,16 @@ type RPCFrontendPacket struct {
// ConnectFrontend connects to the frontend RPC server
func ConnectFrontend() {
var err error
rpcFrontend, err = rpc.Dial("tcp", "localhost:29998")
if err != nil {
panic(err)
for i := 0; rpcFrontend == nil; i++ {
rpcFrontend, err = rpc.Dial("tcp", "localhost:29998")
if err != nil {
if i > 20 {
panic(err)
}
// Sleep for 200 ms before trying again
<-time.After(200 * time.Millisecond)
}
}
}