Fix runtime startup order issues
This commit is contained in:
@@ -2,6 +2,7 @@ package command
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"github.com/owncloud/ocis/ocis/pkg/runtime"
|
||||
"log"
|
||||
"net"
|
||||
"net/rpc"
|
||||
@@ -11,7 +12,6 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/ocis/pkg/config"
|
||||
"github.com/owncloud/ocis/ocis/pkg/register"
|
||||
"github.com/refs/pman/pkg/process"
|
||||
)
|
||||
|
||||
// RunCommand is the entrypoint for the run command.
|
||||
@@ -40,13 +40,7 @@ func RunCommand(cfg *config.Config) *cli.Command {
|
||||
log.Fatal("dialing:", err)
|
||||
}
|
||||
|
||||
proc := process.NewProcEntry(os.Args[2], os.Environ(), []string{os.Args[2]}...)
|
||||
var res int
|
||||
|
||||
if err := client.Call("Service.Start", proc, &res); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
res := runtime.RunService(client, os.Args[2])
|
||||
fmt.Println(res)
|
||||
return nil
|
||||
},
|
||||
|
||||
@@ -33,32 +33,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
r := runtime.New()
|
||||
// TODO temporary service startup selection. Should go away and the runtime should take care of it.
|
||||
return r.Start(append([]string{
|
||||
"proxy",
|
||||
"store",
|
||||
"settings",
|
||||
"phoenix",
|
||||
"ocs",
|
||||
"webdav",
|
||||
"reva-frontend",
|
||||
"reva-gateway",
|
||||
"reva-users",
|
||||
"reva-auth-basic",
|
||||
"reva-auth-bearer",
|
||||
"reva-storage-home",
|
||||
"reva-storage-home-data",
|
||||
"reva-storage-eos",
|
||||
"reva-storage-eos-data",
|
||||
"reva-storage-oc",
|
||||
"reva-storage-oc-data",
|
||||
"reva-storage-public-link",
|
||||
"reva-storage-metadata",
|
||||
"accounts",
|
||||
"glauth",
|
||||
"konnectd",
|
||||
"thumbnails",
|
||||
}, runtime.MicroServices...)...)
|
||||
return r.Start()
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"github.com/micro/cli/v2"
|
||||
)
|
||||
|
||||
// Command adds micro runtime commands to the cli app
|
||||
func Command(app *cli.App) *cli.Command {
|
||||
command := cli.Command{
|
||||
Name: "micro",
|
||||
Description: "starts the go-micro runtime services",
|
||||
Category: "Micro",
|
||||
Action: func(c *cli.Context) error {
|
||||
runtime := New()
|
||||
return runtime.Start()
|
||||
},
|
||||
}
|
||||
return &command
|
||||
}
|
||||
+26
-22
@@ -51,7 +51,6 @@ var (
|
||||
"reva-storage-oc-data",
|
||||
"reva-storage-public-link",
|
||||
"reva-storage-metadata",
|
||||
"accounts",
|
||||
"glauth",
|
||||
"konnectd",
|
||||
"thumbnails",
|
||||
@@ -59,6 +58,7 @@ var (
|
||||
|
||||
// There seem to be a race condition when reva-sharing needs to read the sharing.json file and the parent folder is not present.
|
||||
dependants = []string{
|
||||
"accounts",
|
||||
"reva-sharing",
|
||||
}
|
||||
|
||||
@@ -75,13 +75,13 @@ func New() Runtime {
|
||||
}
|
||||
|
||||
// Start rpc runtime
|
||||
func (r *Runtime) Start(services ...string) error {
|
||||
go r.Launch(services)
|
||||
func (r *Runtime) Start() error {
|
||||
go r.Launch()
|
||||
return service.Start()
|
||||
}
|
||||
|
||||
// Launch ocis default ocis extensions.
|
||||
func (r *Runtime) Launch(services []string) {
|
||||
func (r *Runtime) Launch() {
|
||||
var client *rpc.Client
|
||||
var err error
|
||||
var try int
|
||||
@@ -101,32 +101,36 @@ func (r *Runtime) Launch(services []string) {
|
||||
}
|
||||
|
||||
OUT:
|
||||
for _, v := range services {
|
||||
args := process.NewProcEntry(v, os.Environ(), []string{v}...)
|
||||
var reply int
|
||||
|
||||
if err := client.Call("Service.Start", args, &reply); err != nil {
|
||||
golog.Fatal(err)
|
||||
}
|
||||
for _, v := range MicroServices {
|
||||
RunService(client, v)
|
||||
}
|
||||
|
||||
// TODO(refs) this should disappear and tackled at the runtime (pman) level.
|
||||
// see https://github.com/cs3org/reva/issues/795 for race condition.
|
||||
// dependants might not be needed on a ocis_simple build, therefore
|
||||
// it should not be started under these circumstances.
|
||||
if len(services) >= len(Extensions) { // it will not run for ocis_simple builds.
|
||||
for _, v := range Extensions {
|
||||
RunService(client, v)
|
||||
}
|
||||
|
||||
if len(dependants) > 0 {
|
||||
// TODO(refs) this should disappear and tackled at the runtime (pman) level.
|
||||
// see https://github.com/cs3org/reva/issues/795 for race condition.
|
||||
// dependants might not be needed on a ocis_simple build, therefore
|
||||
// it should not be started under these circumstances.
|
||||
time.Sleep(2 * time.Second)
|
||||
for _, v := range dependants {
|
||||
args := process.NewProcEntry(v, os.Environ(), []string{v}...)
|
||||
var reply int
|
||||
|
||||
if err := client.Call("Service.Start", args, &reply); err != nil {
|
||||
golog.Fatal(err)
|
||||
}
|
||||
RunService(client, v)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// RunService sends a Service.Start command with the given service name to pman
|
||||
func RunService(client *rpc.Client, service string) (reply int) {
|
||||
args := process.NewProcEntry(service, os.Environ(), []string{service}...)
|
||||
|
||||
if err := client.Call("Service.Start", args, &reply); err != nil {
|
||||
golog.Fatal(err)
|
||||
}
|
||||
return
|
||||
}
|
||||
|
||||
// AddMicroPlatform adds the micro subcommands to the cli app
|
||||
func AddMicroPlatform(app *cli.App) {
|
||||
setDefaults()
|
||||
|
||||
Reference in New Issue
Block a user