fix: thread leak

This commit is contained in:
vaalacat 2024-04-15 15:46:58 +00:00
parent e2513dfef0
commit 17ebb42451
2 changed files with 17 additions and 5 deletions

View File

@ -6,19 +6,30 @@ import (
"github.com/VaalaCat/frp-panel/conf"
"github.com/VaalaCat/frp-panel/pb"
"github.com/imroc/req/v3"
"github.com/sirupsen/logrus"
"google.golang.org/grpc"
"google.golang.org/protobuf/proto"
)
func MasterCli(c context.Context) (pb.MasterClient, error) {
var (
masterCli pb.MasterClient
)
func newMasterCli() {
conn, err := grpc.Dial(conf.RPCCallAddr(),
grpc.WithTransportCredentials(conf.ClientCred))
if err != nil {
return nil, err
logrus.Fatalf("did not connect: %v", err)
}
client := pb.NewMasterClient(conn)
return client, nil
masterCli = pb.NewMasterClient(conn)
}
func MasterCli(c context.Context) (pb.MasterClient, error) {
if masterCli == nil {
newMasterCli()
}
return masterCli, nil
}
func GetClientCert(clientID, clientSecret string, clientType pb.ClientType) []byte {

View File

@ -1,9 +1,10 @@
package watcher
import (
"time"
"github.com/go-co-op/gocron/v2"
"github.com/sirupsen/logrus"
"time"
)
type Client interface {