diff --git a/pkg/command/store.go b/pkg/command/store.go index d5ff547f07..7a5e7b92d2 100644 --- a/pkg/command/store.go +++ b/pkg/command/store.go @@ -3,15 +3,10 @@ package command import ( - "context" - "strings" - "time" - "github.com/micro/cli/v2" - "github.com/micro/go-micro/v2" - gostore "github.com/micro/go-micro/v2/store" - "github.com/micro/go-micro/v2/store/file" - "github.com/owncloud/ocis-ocs/pkg/flagset" + "github.com/owncloud/ocis-store/pkg/command" + svcconfig "github.com/owncloud/ocis-store/pkg/config" + "github.com/owncloud/ocis-store/pkg/flagset" "github.com/owncloud/ocis/pkg/config" "github.com/owncloud/ocis/pkg/register" ) @@ -22,37 +17,27 @@ func StoreCommand(cfg *config.Config) *cli.Command { Name: "store", Usage: "Start a go-micro store", Category: "Runtime", - Flags: flagset.ServerWithConfig(cfg.OCS), + Flags: flagset.ServerWithConfig(cfg.Store), Action: func(ctx *cli.Context) error { - file.DefaultDir = "/var/tmp/ocis/store" - store := file.NewStore( - gostore.Database("ocis"), - gostore.Table("ocis"), - gostore.WithContext(context.Background()), - ) + storeCommand := command.Server(configureStore(cfg)) - mopts := []micro.Option{ - micro.Name( - strings.Join( - []string{ - "com.owncloud", - "store", - }, - ".", - ), - ), - micro.RegisterTTL(time.Second * 30), - micro.RegisterInterval(time.Second * 10), - micro.Store(store), + if err := storeCommand.Before(ctx); err != nil { + return err } - service := micro.NewService(mopts...) - service.Init() - return service.Run() + return cli.HandleAction(storeCommand.Action, ctx) }, } } +func configureStore(cfg *config.Config) *svcconfig.Config { + cfg.Store.Log.Level = cfg.Log.Level + cfg.Store.Log.Pretty = cfg.Log.Pretty + cfg.Store.Log.Color = cfg.Log.Color + + return cfg.Store +} + func init() { register.AddCommand(StoreCommand) } diff --git a/pkg/config/config.go b/pkg/config/config.go index 41bba5e060..0a78e51382 100644 --- a/pkg/config/config.go +++ b/pkg/config/config.go @@ -12,6 +12,7 @@ import ( proxy "github.com/owncloud/ocis-proxy/pkg/config" reva "github.com/owncloud/ocis-reva/pkg/config" settings "github.com/owncloud/ocis-settings/pkg/config" + store "github.com/owncloud/ocis-store/pkg/config" thumbnails "github.com/owncloud/ocis-thumbnails/pkg/config" webdav "github.com/owncloud/ocis-webdav/pkg/config" pman "github.com/refs/pman/pkg/config" @@ -74,6 +75,7 @@ type Config struct { Thumbnails *thumbnails.Config WebDAV *webdav.Config Settings *settings.Config + Store *store.Config Runtime *pman.Config } @@ -93,6 +95,7 @@ func New() *Config { Proxy: proxy.New(), Thumbnails: thumbnails.New(), Settings: settings.New(), + Store: store.New(), Runtime: pman.NewConfig(), } } diff --git a/pkg/runtime/runtime.go b/pkg/runtime/runtime.go index 67b88d912c..7ea0a83393 100644 --- a/pkg/runtime/runtime.go +++ b/pkg/runtime/runtime.go @@ -31,6 +31,7 @@ var ( // Extensions are ocis extension services Extensions = []string{ "proxy", + "store", "settings", "phoenix", "graph",