mirror of
https://github.com/WiiLink24/wfc-server.git
synced 2026-04-24 07:27:31 -05:00
Common: Retry frontend connection for 4 seconds
This commit is contained in:
parent
8b9cbbac13
commit
a949b5c727
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user