mirror of
https://github.com/PretendoNetwork/friends.git
synced 2026-04-25 23:37:46 -05:00
Add missing gRPC initialization
This commit is contained in:
parent
a817a7ccd0
commit
179a8221ba
18
init.go
18
init.go
|
|
@ -2,12 +2,17 @@ package main
|
|||
|
||||
import (
|
||||
"encoding/hex"
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
|
||||
"github.com/PretendoNetwork/friends-secure/database"
|
||||
"github.com/PretendoNetwork/friends-secure/globals"
|
||||
"github.com/PretendoNetwork/friends-secure/types"
|
||||
pb "github.com/PretendoNetwork/grpc-go/account"
|
||||
"google.golang.org/grpc"
|
||||
"google.golang.org/grpc/credentials/insecure"
|
||||
"google.golang.org/grpc/metadata"
|
||||
|
||||
"github.com/joho/godotenv"
|
||||
)
|
||||
|
|
@ -19,7 +24,7 @@ func init() {
|
|||
|
||||
err = godotenv.Load()
|
||||
if err != nil {
|
||||
log.Fatal("Error loading .env file")
|
||||
globals.Logger.Warning("Error loading .env file")
|
||||
}
|
||||
|
||||
globals.AESKey, err = hex.DecodeString(os.Getenv("PN_FRIENDS_CONFIG_AES_KEY"))
|
||||
|
|
@ -27,5 +32,16 @@ func init() {
|
|||
log.Fatal(err)
|
||||
}
|
||||
|
||||
globals.GRPCAccountClientConnection, err = grpc.Dial(fmt.Sprintf("%s:%s", os.Getenv("PN_FRIENDS_ACCOUNT_GRPC_HOST"), os.Getenv("PN_FRIENDS_ACCOUNT_GRPC_PORT")), grpc.WithTransportCredentials(insecure.NewCredentials()))
|
||||
if err != nil {
|
||||
globals.Logger.Criticalf("Failed to connect to account gRPC server: %v", err)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
globals.GRPCAccountClient = pb.NewAccountClient(globals.GRPCAccountClientConnection)
|
||||
globals.GRPCAccountCommonMetadata = metadata.Pairs(
|
||||
"X-API-Key", os.Getenv("PN_FRIENDS_ACCOUNT_GRPC_APIKEY"),
|
||||
)
|
||||
|
||||
database.Connect()
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user