Skip to content

Commit 434bbf4

Browse files
committed
changes in server/main.go
1 parent 48f7ab7 commit 434bbf4

File tree

3 files changed

+72
-13
lines changed

3 files changed

+72
-13
lines changed

cmd/server/main.go

+18-12
Original file line numberDiff line numberDiff line change
@@ -7,15 +7,18 @@ import (
77
"krpg/service"
88
"net"
99
"os"
10+
"os/signal"
11+
"syscall"
1012

1113
"github.com/keploy/go-sdk/integrations/kgrpcserver"
1214
"github.com/keploy/go-sdk/keploy"
1315
"google.golang.org/grpc"
1416
)
1517

1618
func main() {
17-
fmt.Println("Starting main function")
18-
port := flag.Int("port", 0, "The port to start the server on")
19+
fmt.Println("Starting gRPC server with Keploy")
20+
21+
port := flag.Int("port", 8000, "The port to start the server on")
1922
flag.Parse()
2023
fmt.Printf("Parsed port: %d\n", *port)
2124

@@ -24,13 +27,9 @@ func main() {
2427
Name: "my-grpc-app",
2528
Port: fmt.Sprintf("%d", *port),
2629
},
27-
Server: keploy.ServerConfig{
28-
URL: "http://localhost:6789/api",
29-
},
3030
})
3131
fmt.Println("Keploy instance created")
3232

33-
fmt.Println("Starting gRPC server setup")
3433
todoServer := service.NewTodoServer()
3534
grpcServer := grpc.NewServer(kgrpcserver.UnaryInterceptor(k))
3635
krpg.RegisterTodoServiceServer(grpcServer, todoServer)
@@ -45,10 +44,17 @@ func main() {
4544
}
4645
fmt.Println("Listener created successfully")
4746

48-
fmt.Println("Starting gRPC server")
49-
err = grpcServer.Serve(listener)
50-
if err != nil {
51-
fmt.Printf("Error starting server: %v\n", err)
52-
os.Exit(1)
53-
}
47+
go func() {
48+
if err := grpcServer.Serve(listener); err != nil {
49+
fmt.Printf("Failed to serve: %v\n", err)
50+
}
51+
}()
52+
53+
sigChan := make(chan os.Signal, 1)
54+
signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
55+
sig := <-sigChan
56+
fmt.Printf("Received signal: %v. Shutting down server...\n", sig)
57+
58+
grpcServer.GracefulStop()
59+
fmt.Println("gRPC server stopped gracefully")
5460
}

keploy-logs.txt

+53
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
🐰 Keploy: 2024-09-22T23:08:32+05:30 [34mINFO[0m keploy initialized and probes added to the kernel.
2+
🐰 Keploy: 2024-09-22T23:08:33+05:30 [34mINFO[0m Keploy has taken control of the DNS resolution mechanism, your application may misbehave if you have provided wrong domain name in your application code.
3+
🐰 Keploy: 2024-09-22T23:08:33+05:30 [34mINFO[0m Proxy started at port:9000
4+
🐰 Keploy: 2024-09-22T23:08:33+05:30 [34mINFO[0m starting TCP DNS server at addr :26789
5+
🐰 Keploy: 2024-09-22T23:08:33+05:30 [34mINFO[0m starting UDP DNS server at addr :26789
6+
🐰 Keploy: 2024-09-22T23:08:33+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:49702", "Client ConnectionID": "0", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "1", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
7+
🐰 Keploy: 2024-09-22T23:08:33+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
8+
🐰 Keploy: 2024-09-22T23:08:34+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:49712", "Client ConnectionID": "2", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "3", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
9+
🐰 Keploy: 2024-09-22T23:08:34+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
10+
🐰 Keploy: 2024-09-22T23:08:36+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:49720", "Client ConnectionID": "4", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "5", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
11+
🐰 Keploy: 2024-09-22T23:08:36+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
12+
🐰 Keploy: 2024-09-22T23:08:38+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:49722", "Client ConnectionID": "6", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "7", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
13+
🐰 Keploy: 2024-09-22T23:08:38+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
14+
🐰 Keploy: 2024-09-22T23:08:43+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:55126", "Client ConnectionID": "8", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "9", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
15+
🐰 Keploy: 2024-09-22T23:08:43+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
16+
🐰 Keploy: 2024-09-22T23:08:49+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:55134", "Client ConnectionID": "10", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "11", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
17+
🐰 Keploy: 2024-09-22T23:08:49+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
18+
🐰 Keploy: 2024-09-22T23:09:00+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:46532", "Client ConnectionID": "12", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "13", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
19+
🐰 Keploy: 2024-09-22T23:09:00+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
20+
🐰 Keploy: 2024-09-22T23:09:16+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:50754", "Client ConnectionID": "14", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "15", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
21+
🐰 Keploy: 2024-09-22T23:09:16+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
22+
🐰 Keploy: 2024-09-22T23:09:48+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:43464", "Client ConnectionID": "16", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "17", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
23+
🐰 Keploy: 2024-09-22T23:09:48+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
24+
🐰 Keploy: 2024-09-22T23:10:27+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:33530", "Client ConnectionID": "18", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "19", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
25+
🐰 Keploy: 2024-09-22T23:10:27+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
26+
🐰 Keploy: 2024-09-22T23:11:39+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:55222", "Client ConnectionID": "20", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "21", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
27+
🐰 Keploy: 2024-09-22T23:11:39+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
28+
🐰 Keploy: 2024-09-22T23:13:19+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:52608", "Client ConnectionID": "22", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "23", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
29+
🐰 Keploy: 2024-09-22T23:13:19+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
30+
🐰 Keploy: 2024-09-22T23:15:18+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:37924", "Client ConnectionID": "24", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "25", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
31+
🐰 Keploy: 2024-09-22T23:15:18+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
32+
🐰 Keploy: 2024-09-22T23:17:07+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:57246", "Client ConnectionID": "26", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "27", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
33+
🐰 Keploy: 2024-09-22T23:17:07+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
34+
🐰 Keploy: 2024-09-22T23:18:53+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:34588", "Client ConnectionID": "28", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "29", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
35+
🐰 Keploy: 2024-09-22T23:18:53+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
36+
🐰 Keploy: 2024-09-22T23:21:12+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:45574", "Client ConnectionID": "30", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "31", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
37+
🐰 Keploy: 2024-09-22T23:21:12+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
38+
🐰 Keploy: 2024-09-22T23:23:02+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:51956", "Client ConnectionID": "32", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "33", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
39+
🐰 Keploy: 2024-09-22T23:23:02+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
40+
🐰 Keploy: 2024-09-22T23:25:14+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:37738", "Client ConnectionID": "34", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "35", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
41+
🐰 Keploy: 2024-09-22T23:25:14+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
42+
🐰 Keploy: 2024-09-22T23:27:32+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:45596", "Client ConnectionID": "36", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "37", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
43+
🐰 Keploy: 2024-09-22T23:27:32+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
44+
🐰 Keploy: 2024-09-22T23:29:14+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:58952", "Client ConnectionID": "38", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "39", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
45+
🐰 Keploy: 2024-09-22T23:29:14+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
46+
🐰 Keploy: 2024-09-22T23:31:01+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:44562", "Client ConnectionID": "40", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "41", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
47+
🐰 Keploy: 2024-09-22T23:31:01+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
48+
🐰 Keploy: 2024-09-22T23:32:39+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:51102", "Client ConnectionID": "42", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "43", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
49+
🐰 Keploy: 2024-09-22T23:32:39+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
50+
🐰 Keploy: 2024-09-22T23:34:33+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:44694", "Client ConnectionID": "44", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "45", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
51+
🐰 Keploy: 2024-09-22T23:34:33+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
52+
🐰 Keploy: 2024-09-22T23:36:55+05:30 [31mERROR[0m failed to dial the conn to destination server {"Client IP Address": "127.0.0.1:59460", "Client ConnectionID": "46", "Destination IP Address": "127.0.0.1:6789", "Destination ConnectionID": "47", "proxy port": 9000, "server address": "127.0.0.1:6789", "error": "dial tcp 127.0.0.1:6789: connect: connection refused"}
53+
🐰 Keploy: 2024-09-22T23:36:55+05:30 [31mERROR[0m failed to handle the client connection {"error": "dial tcp 127.0.0.1:6789: connect: connection refused"}

makefile

+1-1
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ client:
88
go run cmd/client/main.go -address 0.0.0.0:8000
99

1010
keploy:
11-
GOPATH=$(HOME)/go keploy record -c "/usr/local/go/bin/go run cmd/server/main.go -port 8000"
11+
keploy record --command "/usr/local/go/bin/go run cmd/server/main.go -port 8000" --proxy-port 9000
1212

1313
start:
1414
sudo -E make keploy

0 commit comments

Comments
 (0)