From 0453dba7a37b02f7c9f9dd6c0989a00684aa0e3a Mon Sep 17 00:00:00 2001 From: Willy Kloucek Date: Mon, 9 May 2022 13:23:17 +0200 Subject: [PATCH] remove rpc side of kill and run commands --- ocis/pkg/runtime/cmd/kill.go | 35 ----------------------------- ocis/pkg/runtime/cmd/run.go | 33 --------------------------- ocis/pkg/runtime/service/service.go | 35 ----------------------------- 3 files changed, 103 deletions(-) delete mode 100644 ocis/pkg/runtime/cmd/kill.go delete mode 100644 ocis/pkg/runtime/cmd/run.go diff --git a/ocis/pkg/runtime/cmd/kill.go b/ocis/pkg/runtime/cmd/kill.go deleted file mode 100644 index 42622bb3db2..00000000000 --- a/ocis/pkg/runtime/cmd/kill.go +++ /dev/null @@ -1,35 +0,0 @@ -package cmd - -import ( - "fmt" - "log" - "net" - "net/rpc" - - "github.com/owncloud/ocis/v2/ocis/pkg/runtime/config" - "github.com/spf13/cobra" -) - -// Kill an extension. -func Kill(cfg *config.Config) *cobra.Command { - return &cobra.Command{ - Use: "kill", - Aliases: []string{"k"}, - Short: "Kill a running extensions.", - Args: cobra.MinimumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Hostname, cfg.Port)) - if err != nil { - log.Fatal("dialing:", err) - } - - var arg1 int - - if err := client.Call("Service.Kill", &args[0], &arg1); err != nil { - log.Fatal(err) - } - - fmt.Println(arg1) - }, - } -} diff --git a/ocis/pkg/runtime/cmd/run.go b/ocis/pkg/runtime/cmd/run.go deleted file mode 100644 index 83b82add333..00000000000 --- a/ocis/pkg/runtime/cmd/run.go +++ /dev/null @@ -1,33 +0,0 @@ -package cmd - -import ( - "fmt" - "log" - "net" - "net/rpc" - - "github.com/owncloud/ocis/v2/ocis/pkg/runtime/config" - "github.com/spf13/cobra" -) - -// Run an extension. -func Run(cfg *config.Config) *cobra.Command { - return &cobra.Command{ - Use: "run", - Short: "Run an extension.", - Args: cobra.MinimumNArgs(1), - Run: func(cmd *cobra.Command, args []string) { - client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Hostname, cfg.Port)) - if err != nil { - log.Fatal("dialing:", err) - } - var res int - - if err = client.Call("Service.Start", &args[0], &res); err != nil { - log.Fatal(err) - } - - fmt.Println(res) - }, - } -} diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 4d5b30c6184..5d07f08afee 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -274,25 +274,6 @@ func (s *Service) generateRunSet(cfg *ociscfg.Config) { } } -// Start indicates the Service Controller to start a new supervised service as an OS thread. -func (s *Service) Start(name string, reply *int) error { - swap := deepcopy.Copy(s.cfg) - if _, ok := s.ServicesRegistry[name]; ok { - *reply = 0 - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](swap.(*ociscfg.Config)))) - return nil - } - - if _, ok := s.Delayed[name]; ok { - *reply = 0 - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](swap.(*ociscfg.Config)))) - return nil - } - - *reply = 0 - return fmt.Errorf("cannot start service %s: unknown service", name) -} - // List running processes for the Service Controller. func (s *Service) List(args struct{}, reply *string) error { tableString := &strings.Builder{} @@ -317,22 +298,6 @@ func (s *Service) List(args struct{}, reply *string) error { return nil } -// Kill a supervised process by subcommand name. -func (s *Service) Kill(name string, reply *int) error { - if len(s.serviceToken[name]) > 0 { - for i := range s.serviceToken[name] { - if err := s.Supervisor.RemoveAndWait(s.serviceToken[name][i], 5000*time.Millisecond); err != nil { - return err - } - } - delete(s.serviceToken, name) - } else { - return fmt.Errorf("service %s not found", name) - } - - return nil -} - // trap blocks on halt channel. When the runtime is interrupted it // signals the controller to stop any supervised process. func trap(s *Service, halt chan os.Signal) {