remove run and kill commands from the runtime

This commit is contained in:
Willy Kloucek
2022-05-09 11:31:26 +02:00
parent 93b54b9144
commit a793a4d1e6
3 changed files with 10 additions and 111 deletions

View File

@@ -0,0 +1,10 @@
Bugfix: Remove runtime kill and run commands
We've removed the kill and run commands from the oCIS runtime.
If these dynamic capabilities are needed, one should switch to a full fledged
supervisor and start oCIS as individual services.
If one wants to start a only a subset of services, this is still possible
by setting OCIS_RUN_EXTENSIONS.
https://github.com/owncloud/ocis/pull/3740

View File

@@ -1,55 +0,0 @@
package command
import (
"fmt"
"log"
"net"
"net/rpc"
"os"
"github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis/pkg/register"
"github.com/urfave/cli/v2"
)
// KillCommand is the entrypoint for the kill command.
func KillCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "kill",
Usage: "kill an extension by name in the runtime (supervised mode)",
Category: "runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOST"},
Destination: &cfg.Runtime.Host,
},
&cli.StringFlag{
Name: "port",
Value: "9250",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Host, cfg.Runtime.Port))
if err != nil {
log.Fatalf("Failed to connect to the runtime. Has the runtime been started and did you configure the right runtime address (\"%s\")", cfg.Runtime.Host+":"+cfg.Runtime.Port)
}
var arg1 int
if err := client.Call("Service.Kill", os.Args[2], &arg1); err != nil {
log.Fatal(err)
}
fmt.Printf("process %v terminated", os.Args[2])
return nil
},
}
}
func init() {
register.AddCommand(KillCommand)
}

View File

@@ -1,56 +0,0 @@
package command
import (
"fmt"
"log"
"net"
"net/rpc"
"os"
cli "github.com/urfave/cli/v2"
"github.com/owncloud/ocis/v2/ocis-pkg/config"
"github.com/owncloud/ocis/v2/ocis/pkg/register"
)
// RunCommand is the entrypoint for the run command.
func RunCommand(cfg *config.Config) *cli.Command {
return &cli.Command{
Name: "run",
Usage: "run an extension by name in the runtime (supervised mode)",
Category: "runtime",
Flags: []cli.Flag{
&cli.StringFlag{
Name: "hostname",
Value: "localhost",
EnvVars: []string{"OCIS_RUNTIME_HOST"},
Destination: &cfg.Runtime.Host,
},
&cli.StringFlag{
Name: "port",
Value: "9250",
EnvVars: []string{"OCIS_RUNTIME_PORT"},
Destination: &cfg.Runtime.Port,
},
},
Action: func(c *cli.Context) error {
client, err := rpc.DialHTTP("tcp", net.JoinHostPort(cfg.Runtime.Host, cfg.Runtime.Port))
if err != nil {
log.Fatalf("Failed to connect to the runtime. Has the runtime been started and did you configure the right runtime address (\"%s\")", cfg.Runtime.Host+":"+cfg.Runtime.Port)
}
var reply int
if err := client.Call("Service.Start", os.Args[2], &reply); err != nil {
log.Fatal(err)
}
fmt.Println(reply)
return nil
},
}
}
func init() {
register.AddCommand(RunCommand)
}