Fix store command
- Was started with the wrong flagset - Didn't use the ocis-store config at all
This commit is contained in:
+16
-31
@@ -3,15 +3,10 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
|
||||||
"strings"
|
|
||||||
"time"
|
|
||||||
|
|
||||||
"github.com/micro/cli/v2"
|
"github.com/micro/cli/v2"
|
||||||
"github.com/micro/go-micro/v2"
|
"github.com/owncloud/ocis-store/pkg/command"
|
||||||
gostore "github.com/micro/go-micro/v2/store"
|
svcconfig "github.com/owncloud/ocis-store/pkg/config"
|
||||||
"github.com/micro/go-micro/v2/store/file"
|
"github.com/owncloud/ocis-store/pkg/flagset"
|
||||||
"github.com/owncloud/ocis-ocs/pkg/flagset"
|
|
||||||
"github.com/owncloud/ocis/pkg/config"
|
"github.com/owncloud/ocis/pkg/config"
|
||||||
"github.com/owncloud/ocis/pkg/register"
|
"github.com/owncloud/ocis/pkg/register"
|
||||||
)
|
)
|
||||||
@@ -22,37 +17,27 @@ func StoreCommand(cfg *config.Config) *cli.Command {
|
|||||||
Name: "store",
|
Name: "store",
|
||||||
Usage: "Start a go-micro store",
|
Usage: "Start a go-micro store",
|
||||||
Category: "Runtime",
|
Category: "Runtime",
|
||||||
Flags: flagset.ServerWithConfig(cfg.OCS),
|
Flags: flagset.ServerWithConfig(cfg.Store),
|
||||||
Action: func(ctx *cli.Context) error {
|
Action: func(ctx *cli.Context) error {
|
||||||
file.DefaultDir = "/var/tmp/ocis/store"
|
storeCommand := command.Server(configureStore(cfg))
|
||||||
store := file.NewStore(
|
|
||||||
gostore.Database("ocis"),
|
|
||||||
gostore.Table("ocis"),
|
|
||||||
gostore.WithContext(context.Background()),
|
|
||||||
)
|
|
||||||
|
|
||||||
mopts := []micro.Option{
|
if err := storeCommand.Before(ctx); err != nil {
|
||||||
micro.Name(
|
return err
|
||||||
strings.Join(
|
|
||||||
[]string{
|
|
||||||
"com.owncloud",
|
|
||||||
"store",
|
|
||||||
},
|
|
||||||
".",
|
|
||||||
),
|
|
||||||
),
|
|
||||||
micro.RegisterTTL(time.Second * 30),
|
|
||||||
micro.RegisterInterval(time.Second * 10),
|
|
||||||
micro.Store(store),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
service := micro.NewService(mopts...)
|
return cli.HandleAction(storeCommand.Action, ctx)
|
||||||
service.Init()
|
|
||||||
return service.Run()
|
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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() {
|
func init() {
|
||||||
register.AddCommand(StoreCommand)
|
register.AddCommand(StoreCommand)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,6 +12,7 @@ import (
|
|||||||
proxy "github.com/owncloud/ocis-proxy/pkg/config"
|
proxy "github.com/owncloud/ocis-proxy/pkg/config"
|
||||||
reva "github.com/owncloud/ocis-reva/pkg/config"
|
reva "github.com/owncloud/ocis-reva/pkg/config"
|
||||||
settings "github.com/owncloud/ocis-settings/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"
|
thumbnails "github.com/owncloud/ocis-thumbnails/pkg/config"
|
||||||
webdav "github.com/owncloud/ocis-webdav/pkg/config"
|
webdav "github.com/owncloud/ocis-webdav/pkg/config"
|
||||||
pman "github.com/refs/pman/pkg/config"
|
pman "github.com/refs/pman/pkg/config"
|
||||||
@@ -74,6 +75,7 @@ type Config struct {
|
|||||||
Thumbnails *thumbnails.Config
|
Thumbnails *thumbnails.Config
|
||||||
WebDAV *webdav.Config
|
WebDAV *webdav.Config
|
||||||
Settings *settings.Config
|
Settings *settings.Config
|
||||||
|
Store *store.Config
|
||||||
Runtime *pman.Config
|
Runtime *pman.Config
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -93,6 +95,7 @@ func New() *Config {
|
|||||||
Proxy: proxy.New(),
|
Proxy: proxy.New(),
|
||||||
Thumbnails: thumbnails.New(),
|
Thumbnails: thumbnails.New(),
|
||||||
Settings: settings.New(),
|
Settings: settings.New(),
|
||||||
|
Store: store.New(),
|
||||||
Runtime: pman.NewConfig(),
|
Runtime: pman.NewConfig(),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,6 +31,7 @@ var (
|
|||||||
// Extensions are ocis extension services
|
// Extensions are ocis extension services
|
||||||
Extensions = []string{
|
Extensions = []string{
|
||||||
"proxy",
|
"proxy",
|
||||||
|
"store",
|
||||||
"settings",
|
"settings",
|
||||||
"phoenix",
|
"phoenix",
|
||||||
"graph",
|
"graph",
|
||||||
|
|||||||
Reference in New Issue
Block a user