remove rpc side of kill and run commands
This commit is contained in:
@@ -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)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -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)
|
||||
},
|
||||
}
|
||||
}
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user