diff --git a/go.mod b/go.mod index f09d4376d..a1a9aa52b 100644 --- a/go.mod +++ b/go.mod @@ -57,3 +57,5 @@ require ( replace google.golang.org/grpc => google.golang.org/grpc v1.26.0 replace github.com/lucas-clemente/quic-go v0.15.7 => github.com/lucas-clemente/quic-go v0.14.1 + +replace github.com/owncloud/ocis-hello => ../ocis-hello diff --git a/go.sum b/go.sum index 83866f4ca..644b70f58 100644 --- a/go.sum +++ b/go.sum @@ -363,6 +363,8 @@ github.com/go-chi/chi v4.0.2+incompatible h1:maB6vn6FqCxrpz4FqWdh4+lwpyZIQS7YEAU github.com/go-chi/chi v4.0.2+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/chi v4.1.0+incompatible h1:ETj3cggsVIY2Xao5ExCu6YhEh5MD6JTfcBzS37R260w= github.com/go-chi/chi v4.1.0+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= +github.com/go-chi/chi v4.1.1+incompatible h1:MmTgB0R8Bt/jccxp+t6S/1VGIKdJw5J74CK/c9tTfA4= +github.com/go-chi/chi v4.1.1+incompatible/go.mod h1:eB3wogJHnLi3x/kFX2A+IbTBlXxmMeXJVKy9tTv1XzQ= github.com/go-chi/render v1.0.1 h1:4/5tis2cKaNdnv9zFLfXzcquC9HbeZgCnxGnKrltBS8= github.com/go-chi/render v1.0.1/go.mod h1:pq4Rr7HbnsdaeHagklXub+p6Wd16Af5l9koip1OvJns= github.com/go-cmd/cmd v1.0.5/go.mod h1:y8q8qlK5wQibcw63djSl/ntiHUHXHGdCkPk0j4QeW4s= @@ -733,6 +735,7 @@ github.com/hashicorp/go-sockaddr v1.0.2/go.mod h1:rB4wwRAUzs07qva3c5SdrY/NEtAUjG github.com/hashicorp/go-syslog v1.0.0/go.mod h1:qPfqrKkXGihmCqbJM2mZgkZGvKG1dFdvsLplgctolz4= github.com/hashicorp/go-uuid v1.0.0/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= github.com/hashicorp/go-uuid v1.0.1/go.mod h1:6SBZvOh/SIDV7/2o3Jml5SYk/TvGqwFJ/bN7x4byOro= +github.com/hashicorp/go-version v1.0.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go-version v1.1.0/go.mod h1:fltr4n8CU8Ke44wwGCBoEymUuxUHl09ZGVZPK5anwXA= github.com/hashicorp/go.net v0.0.1/go.mod h1:hjKkEWcCURg++eb33jQU7oqQcI9XDCnUzHA0oac0k90= github.com/hashicorp/golang-lru v0.5.0/go.mod h1:/m3WP610KZHVQ1SGc6re/UDhFvYD7pJ4Ao+sR/qLZy8= @@ -931,6 +934,7 @@ github.com/micro/go-micro v1.18.0/go.mod h1:klwUJL1gkdY1MHFyz+fFJXn52dKcty4hoe95 github.com/micro/go-micro/v2 v2.0.0/go.mod h1:v7QP5UhKRt37ixjJe8DouWmg0/eE6dltr5h0idJ9BpE= github.com/micro/go-micro/v2 v2.0.1-0.20200207205803-ef537270add3/go.mod h1:CDPVByZzOp1RNrJfNxEGgNOJ11wEw8NoHfADo8M3+LM= github.com/micro/go-micro/v2 v2.0.1-0.20200212105717-d76baf59de2e/go.mod h1:CDPVByZzOp1RNrJfNxEGgNOJ11wEw8NoHfADo8M3+LM= +github.com/micro/go-micro/v2 v2.5.1-0.20200417165434-16db76bee2fb/go.mod h1:qz2UT4UFdFVs+qUGMuDK3xuHgude1BgntqQ29sbpPlE= github.com/micro/go-micro/v2 v2.6.0 h1:HH6uEqTu6pkBtAlwAqQW2sf33640iEa1s9puGIctpO0= github.com/micro/go-micro/v2 v2.6.0/go.mod h1:60HMKlDN4ShZDJRrlgdcAmkCWNhQbYv+CDG3r7iLE34= github.com/micro/go-micro/v2 v2.7.0 h1:oWmCoA81Z7kCk26hiRGNrlJ8TWmpb3/ImO0EYdhoXBw= @@ -977,6 +981,7 @@ github.com/mitchellh/go-wordwrap v0.0.0-20150314170334-ad45545899c7/go.mod h1:ZX github.com/mitchellh/go-wordwrap v1.0.0 h1:6GlHJ/LTGMrIJbwgdqdl2eEH8o+Exx/0m8ir9Gns0u4= github.com/mitchellh/go-wordwrap v1.0.0/go.mod h1:ZXFpozHsX6DPmq2I0TCekCxypsnAUbP2oI0UX1GXzOo= github.com/mitchellh/gox v0.4.0/go.mod h1:Sd9lOJ0+aimLBi73mGofS1ycjY8lL3uZM3JPS42BGNg= +github.com/mitchellh/gox v1.0.1/go.mod h1:ED6BioOGXMswlXa2zxfh/xdd5QhwYliBFn9V18Ap4z4= github.com/mitchellh/hashstructure v1.0.0 h1:ZkRJX1CyOoTkar7p/mLS5TZU4nJ1Rn/F8u9dGS02Q3Y= github.com/mitchellh/hashstructure v1.0.0/go.mod h1:QjSHrPWS+BGUVBYkbTZWEnOh3G1DutKwClXU/ABz6AQ= github.com/mitchellh/iochan v1.0.0/go.mod h1:JwYml1nuB7xOzsp52dPpHFffvOCDupsG0QubkSMEySY= @@ -1221,6 +1226,8 @@ github.com/prometheus/client_golang v1.1.0/go.mod h1:I1FGZT9+L76gKKOs5djB6ezCbFQ github.com/prometheus/client_golang v1.2.1/go.mod h1:XMU6Z2MjaRKVu/dC1qupJI9SiNkDYzz3xecMgSW/F+U= github.com/prometheus/client_golang v1.4.1 h1:FFSuS004yOQEtDdTq+TAOLP5xUq63KqAFYyOi8zA+Y8= github.com/prometheus/client_golang v1.4.1/go.mod h1:e9GMxYsXl05ICDXkRhurwBS4Q3OK1iX/F2sw+iXX5zU= +github.com/prometheus/client_golang v1.6.0 h1:YVPodQOcK15POxhgARIvnDRVpLcuK8mglnMrWfyrw6A= +github.com/prometheus/client_golang v1.6.0/go.mod h1:ZLOG9ck3JLRdB5MgO8f+lLTe83AXG6ro35rLTxvnIl4= github.com/prometheus/client_model v0.0.0-20170216185247-6f3806018612/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20180712105110-5c3871d89910/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= github.com/prometheus/client_model v0.0.0-20190115171406-56726106282f/go.mod h1:MbSGuTsp3dbXC40dX6PRTWyKYBIrTGTE9sqQNg2J8bo= @@ -1249,6 +1256,8 @@ github.com/prometheus/procfs v0.0.3/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDa github.com/prometheus/procfs v0.0.5/go.mod h1:4A/X28fw3Fc593LaREMrKMqOKvUAntwMDaekg4FpcdQ= github.com/prometheus/procfs v0.0.8 h1:+fpWZdT24pJBiqJdAwYBjPSk+5YmQzYNPYzQsdzLkt8= github.com/prometheus/procfs v0.0.8/go.mod h1:7Qr8sr6344vo1JqZ6HhLceV9o3AJ1Ff+GxbHq6oeK9A= +github.com/prometheus/procfs v0.0.11 h1:DhHlBtkHWPYi8O2y31JkK0TF+DGM+51OopZjH/Ia5qI= +github.com/prometheus/procfs v0.0.11/go.mod h1:lV6e/gmhEcM9IjHGsFOCxxuZ+z1YqCvr4OA4YeYWdaU= github.com/prometheus/tsdb v0.7.1/go.mod h1:qhTCs0VvXwvX/y3TZrWD7rabWM+ijKTux40TwIPHuXU= github.com/rainycape/memcache v0.0.0-20150622160815-1031fa0ce2f2/go.mod h1:7tZKcyumwBO6qip7RNQ5r77yrssm9bfCowcLEBcU5IA= github.com/rcrowley/go-metrics v0.0.0-20181016184325-3113b8401b8a/go.mod h1:bCqnVzQkZxMG4s8nGwiZ5l3QUCyqpo9Y+/ZMZ9VjZe4= @@ -1604,6 +1613,7 @@ golang.org/x/net v0.0.0-20200222125558-5a598a2470a0/go.mod h1:z5CRVTTTmAJ677TzLL golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200301022130-244492dfa37a/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20200324143707-d3edc9973b7e/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= +golang.org/x/net v0.0.0-20200506145744-7e3656a0809f/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2 h1:eDrdRpKgkcCqKZQwyZRyeFZgfqt37SL7Kv3tok06cKE= golang.org/x/net v0.0.0-20200520182314-0ba52f642ac2/go.mod h1:qpuaurCH72eLCgpAm/N6yyVIVM9cpaDIP3A8BGJEC5A= golang.org/x/oauth2 v0.0.0-20180821212333-d2e6202438be/go.mod h1:N/0e6XlmueqKjAGxoOufVs8QHGRruUQn6yWY3a++T0U= @@ -1683,6 +1693,7 @@ golang.org/x/sys v0.0.0-20191105231009-c1f44814a5cd/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191110163157-d32e6e3b99c4/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20191128015809-6d18c012aee9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200103143344-a1369afcdac7/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200106162015-b016eb3dc98e/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200122134326-e047566fdf82/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200202164722-d101bd2416d5/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= @@ -1693,6 +1704,7 @@ golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae h1:/WDfKMnPU+m5M4xB+6x4kaepx golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200302150141-5c8b2ff67527/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200323222414-85ca7c5b95cd/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20200420163511-1957bb5e6d1f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200523222454-059865788121 h1:rITEj+UZHYC927n8GT97eC3zrpzXdb/voyeOuVKS46o= golang.org/x/sys v0.0.0-20200523222454-059865788121/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/text v0.0.0-20160726164857-2910a502d2bf/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= diff --git a/pkg/command/accounts.go b/pkg/command/accounts.go index 88b3b6edd..b44934939 100644 --- a/pkg/command/accounts.go +++ b/pkg/command/accounts.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/migration-import.go b/pkg/command/migration-import.go index c880528af..4c9d5891d 100644 --- a/pkg/command/migration-import.go +++ b/pkg/command/migration-import.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/proxy.go b/pkg/command/proxy.go index 3ceb8b3a4..799c830b4 100644 --- a/pkg/command/proxy.go +++ b/pkg/command/proxy.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/reva-storage-public-link.go b/pkg/command/reva-storage-public-link.go index 1e3b558c8..d9ebbbb62 100644 --- a/pkg/command/reva-storage-public-link.go +++ b/pkg/command/reva-storage-public-link.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revaauthbasic.go b/pkg/command/revaauthbasic.go index 99368710a..17133effc 100644 --- a/pkg/command/revaauthbasic.go +++ b/pkg/command/revaauthbasic.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revaauthbearer.go b/pkg/command/revaauthbearer.go index 82dc7801c..ddcdca2b0 100644 --- a/pkg/command/revaauthbearer.go +++ b/pkg/command/revaauthbearer.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revafrontend.go b/pkg/command/revafrontend.go index 92e352cef..30d47b2ee 100644 --- a/pkg/command/revafrontend.go +++ b/pkg/command/revafrontend.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revagateway.go b/pkg/command/revagateway.go index ee674c6a6..8b8a57f88 100644 --- a/pkg/command/revagateway.go +++ b/pkg/command/revagateway.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revasharing.go b/pkg/command/revasharing.go index 18f84953d..ebeafa548 100644 --- a/pkg/command/revasharing.go +++ b/pkg/command/revasharing.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastorageeos.go b/pkg/command/revastorageeos.go index 13a428c02..6a9ca26a8 100644 --- a/pkg/command/revastorageeos.go +++ b/pkg/command/revastorageeos.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastorageeosdata.go b/pkg/command/revastorageeosdata.go index f78668284..9c5ed0a56 100644 --- a/pkg/command/revastorageeosdata.go +++ b/pkg/command/revastorageeosdata.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastoragehome.go b/pkg/command/revastoragehome.go index 0608b34ae..377648641 100644 --- a/pkg/command/revastoragehome.go +++ b/pkg/command/revastoragehome.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastoragehomedata.go b/pkg/command/revastoragehomedata.go index 3d7f04f16..2300e39f5 100644 --- a/pkg/command/revastoragehomedata.go +++ b/pkg/command/revastoragehomedata.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastorageoc.go b/pkg/command/revastorageoc.go index 8f9e950d7..58e5c84b7 100644 --- a/pkg/command/revastorageoc.go +++ b/pkg/command/revastorageoc.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastorageocdata.go b/pkg/command/revastorageocdata.go index f9d7e7a5a..3cbad83c2 100644 --- a/pkg/command/revastorageocdata.go +++ b/pkg/command/revastorageocdata.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revastorageroot.go b/pkg/command/revastorageroot.go index 65887124e..1c370f42e 100644 --- a/pkg/command/revastorageroot.go +++ b/pkg/command/revastorageroot.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/revausers.go b/pkg/command/revausers.go index 33a2f404e..b6119b290 100644 --- a/pkg/command/revausers.go +++ b/pkg/command/revausers.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/server.go b/pkg/command/server.go index f04c774c1..b0b4a3152 100644 --- a/pkg/command/server.go +++ b/pkg/command/server.go @@ -32,8 +32,8 @@ func Server(cfg *config.Config) *cli.Command { return err } - runtime := runtime.New() - return runtime.Start() + r := runtime.New() + return r.Start(append(runtime.Extensions, runtime.MicroServices...)...) }, } } diff --git a/pkg/command/server_simple.go b/pkg/command/server_simple.go index c619f8b72..a89399fa1 100644 --- a/pkg/command/server_simple.go +++ b/pkg/command/server_simple.go @@ -42,8 +42,8 @@ func Simple(cfg *config.Config) *cli.Command { return err } - runtime := runtime.New() - runtime.Start() + r := runtime.New() + r.Start(append(SimpleRuntimeServices, runtime.MicroServices...)...) return nil }, diff --git a/pkg/command/settings.go b/pkg/command/settings.go index 777c410f0..71498da51 100644 --- a/pkg/command/settings.go +++ b/pkg/command/settings.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/command/thumbnails.go b/pkg/command/thumbnails.go index 57cfaf142..717860380 100644 --- a/pkg/command/thumbnails.go +++ b/pkg/command/thumbnails.go @@ -1,3 +1,5 @@ +// +build !simple + package command import ( diff --git a/pkg/micro/runtime/runtime.go b/pkg/micro/runtime/runtime.go deleted file mode 100644 index 2a93898f9..000000000 --- a/pkg/micro/runtime/runtime.go +++ /dev/null @@ -1,146 +0,0 @@ -package runtime - -import ( - "fmt" - golog "log" - "net/rpc" - "time" - - "github.com/micro/cli/v2" - - "github.com/micro/micro/v2/client/api" - "github.com/micro/micro/v2/client/web" - "github.com/micro/micro/v2/service/registry" - - "github.com/refs/pman/pkg/process" - "github.com/refs/pman/pkg/service" -) - -var ( - // OwncloudNamespace is the base path for micro' services to use - OwncloudNamespace = "com.owncloud." - - // MicroServices to start as part of the fullstack option - MicroServices = []string{ - "api", // :8080 - "web", // :8082 - "registry", // :8000 - } - - // Extensions are ocis extension services - Extensions = []string{ - "proxy", - "settings", - "phoenix", - "graph", - "graph-explorer", - "ocs", - "webdav", - "reva-frontend", - "reva-gateway", - "reva-users", - "reva-auth-basic", - "reva-auth-bearer", - // "reva-storage-root", - "reva-storage-home", - "reva-storage-public-link", - "reva-storage-home-data", - "reva-storage-eos", - "reva-storage-eos-data", - "reva-storage-oc", - "reva-storage-oc-data", - "accounts", - "glauth", - "konnectd", - "thumbnails", - } - - // 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{ - "reva-sharing", - } - - // Maximum number of retries until getting a connection to the rpc runtime service. - maxRetries int = 10 -) - -// Runtime represents an oCIS runtime environment. -type Runtime struct{} - -// New creates a new ocis + micro runtime -func New() Runtime { - return Runtime{} -} - -// Start rpc runtime -func (r *Runtime) Start() error { - go r.Launch() - return service.Start() -} - -// Launch ocis default ocis extensions. -func (r *Runtime) Launch() { - var client *rpc.Client - var err error - var try int - - for { - if try >= maxRetries { - golog.Fatal("could not get a connection to rpc runtime on localhost:10666") - } - client, err = rpc.DialHTTP("tcp", "localhost:10666") - if err != nil { - try++ - fmt.Println("runtime not available, retrying in 1 second...") - time.Sleep(1 * time.Second) - } else { - goto OUT - } - } - -OUT: - all := append(Extensions, MicroServices...) - for _, v := range all { - args := process.NewProcEntry(v, []string{v}...) - var reply int - - if err := client.Call("Service.Start", args, &reply); err != nil { - golog.Fatal(err) - } - } - - // ugly hack to avoid dependencies. - time.Sleep(2 * time.Second) - for _, v := range dependants { - args := process.NewProcEntry(v, []string{v}...) - var reply int - - if err := client.Call("Service.Start", args, &reply); err != nil { - golog.Fatal(err) - } - } -} - -// AddMicroPlatform adds the micro subcommands to the cli app -func AddMicroPlatform(app *cli.App) { - setDefaults() - - app.Commands = append(app.Commands, api.Commands()...) - app.Commands = append(app.Commands, web.Commands()...) - app.Commands = append(app.Commands, registry.Commands()...) -} - -// provide a config.Config with default values? -func setDefaults() { - // api - api.Name = OwncloudNamespace + "api" - api.Namespace = OwncloudNamespace + "api" - api.HeaderPrefix = "X-Micro-Owncloud-" - - // web - web.Name = OwncloudNamespace + "web" - web.Namespace = OwncloudNamespace + "web" - - // registry - registry.Name = OwncloudNamespace + "registry" -} diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 46af26ae1..090bfab2d 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -4,7 +4,6 @@ import ( "fmt" golog "log" "net/rpc" - "sync" "time" "github.com/micro/cli/v2" @@ -66,37 +65,24 @@ var ( ) // Runtime represents an oCIS runtime environment. -type Runtime struct { - extensions []string - dependants []string -} +type Runtime struct{} // New creates a new ocis + micro runtime -func New(extensions ...string) Runtime { - r := Runtime{ - extensions: append(Extensions, MicroServices...), - dependants: dependants, - } - - if extensions != nil { - r.extensions = extensions - } - - return r +func New() Runtime { + return Runtime{} } // Start rpc runtime -func (r *Runtime) Start() error { - go r.Launch() +func (r *Runtime) Start(services ...string) error { + go r.Launch(services) return service.Start() } // Launch ocis default ocis extensions. -func (r *Runtime) Launch() { +func (r *Runtime) Launch(services []string) { var client *rpc.Client var err error var try int - wg := &sync.WaitGroup{} for { if try >= maxRetries { @@ -113,7 +99,7 @@ func (r *Runtime) Launch() { } OUT: - for _, v := range r.extensions { + for _, v := range services { args := process.NewProcEntry(v, []string{v}...) var reply int @@ -122,32 +108,21 @@ OUT: } } - // ugly hack to avoid dependencies. - for _, v := range r.dependants { - args := process.NewProcEntry(v, []string{v}...) - wg.Add(len(r.dependants)) - go delayedRun(client, &args, wg) - } + // 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. + time.Sleep(2 * time.Second) + for _, v := range dependants { + args := process.NewProcEntry(v, []string{v}...) + var reply int - wg.Wait() -} - -func delayedRun(c *rpc.Client, p *process.ProcEntry, wg *sync.WaitGroup) error { - var retries, reply int - for { - if retries >= maxRetries { - return fmt.Errorf("maximum number of retries on extension: `%v`", p.Extension) + if err := client.Call("Service.Start", args, &reply); err != nil { + golog.Fatal(err) + } } - time.Sleep(1 * time.Second) - if err := c.Call("Service.Start", p, &reply); err == nil { - goto OUT - } - fmt.Printf("try %v #%v", p.Extension, retries) - retries++ } -OUT: - wg.Done() - return nil } // AddMicroPlatform adds the micro subcommands to the cli app