mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-02-27 08:20:26 -06:00
Fix store command
- Was started with the wrong flagset - Didn't use the ocis-store config at all
This commit is contained in:
committed by
Artur Neumann
parent
75e9506254
commit
1b048da76a
@@ -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)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user