diff --git a/cliInterface/gosdnCLI.proto b/cliInterface/gosdnCLI.proto index e53443f18a8ccb3c02ca38d373dc68d940d35fd4..2139a330110a5b8c9909083370de24f5d10bbeca 100644 --- a/cliInterface/gosdnCLI.proto +++ b/cliInterface/gosdnCLI.proto @@ -12,6 +12,8 @@ package cliInterface; service Greeter { // Sends a greeting rpc SayHello (HelloRequest) returns (HelloReply) {} + // Shutdown goSDN + rpc Shutdown (ShutdownRequest) returns (ShutdownReply) {} } // The request message containing the user's name. @@ -23,3 +25,14 @@ message HelloRequest { message HelloReply { string message = 1; } + +// Request to shutdown goSDN +message ShutdownRequest { + string name = 1; +} + +// The response message containing some shutdown notes of goSDN +message ShutdownReply { + string message = 1; +} + diff --git a/gosdn-cli/gosdn-cli.go b/gosdn-cli/gosdn-cli.go index bb350220092ea4c2443f9663edad9ba2f9e18627..1c15073d8ade442f802220745728f6d486ce6cc9 100644 --- a/gosdn-cli/gosdn-cli.go +++ b/gosdn-cli/gosdn-cli.go @@ -18,6 +18,7 @@ const ( func main() { // Set up a connection to the server. + address := "localhost:55055" conn, err := grpc.Dial(address, grpc.WithInsecure(), grpc.WithBlock()) if err != nil { log.Fatalf("did not connect: %v", err) @@ -37,4 +38,10 @@ func main() { log.Fatalf("could not greet: %v", err) } log.Printf("Greeting: %s", r.GetMessage()) + + r2, err := c.Shutdown(ctx, &pb.ShutdownRequest{Name: name}) + if err != nil { + log.Fatalf("could not greet: %v", err) + } + log.Printf("Greeting: %s", r2.GetMessage()) } diff --git a/nucleus/nucleus-core.go b/nucleus/nucleus-core.go index 93d9bbe39cda59a0f732ace24523c11e617e24c5..d07c6e28e42a391087a42b17a37316a24f9d5039 100644 --- a/nucleus/nucleus-core.go +++ b/nucleus/nucleus-core.go @@ -26,6 +26,13 @@ func (s *server) SayHello(ctx context.Context, in *pb.HelloRequest) (*pb.HelloRe return &pb.HelloReply{Message: "Hello " + in.GetName()}, nil } +func (s *server) Shutdown(ctx context.Context, in *pb.ShutdownRequest) (*pb.ShutdownReply, error) { + log.Printf("Received: %v", in.GetName()) + isRunning = false + return &pb.ShutdownReply{Message: "Shutdown " + in.GetName()}, nil +} + + func getCLIGoing() { log.Println("Starting: GetCLIGoing") // Boot-up the control interface for the cli @@ -63,12 +70,13 @@ func StartUp() { * nucleus.Run() is the "main loop" of the controller */ +var isRunning = true + func Run() { - isRunning := true for isRunning { time.Sleep(10 * time.Second) - isRunning = false + log.Println(("Still alive...")) } log.Println("Good bye....!")