update commands when running in supervised mode

This commit is contained in:
A.Unger
2021-03-10 11:10:46 +01:00
parent 25909d5923
commit 4e37d4a2f6
72 changed files with 1547 additions and 803 deletions
+11 -35
View File
@@ -4,20 +4,20 @@ import (
"context"
"flag"
"os"
"os/signal"
"path"
"path/filepath"
"time"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/thejerf/suture"
"github.com/owncloud/ocis/ocis-pkg/sync"
"github.com/cs3org/reva/cmd/revad/runtime"
"github.com/gofrs/uuid"
"github.com/micro/cli/v2"
"github.com/oklog/run"
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
"github.com/owncloud/ocis/storage/pkg/config"
"github.com/owncloud/ocis/storage/pkg/flagset"
"github.com/owncloud/ocis/storage/pkg/server/debug"
"github.com/thejerf/suture"
)
// Sharing is the entrypoint for the sharing command.
@@ -164,40 +164,13 @@ func Sharing(cfg *config.Config) *cli.Command {
return err
}
gr.Add(func() error {
return server.ListenAndServe()
}, func(_ error) {
ctx, timeout := context.WithTimeout(ctx, 5*time.Second)
defer timeout()
defer cancel()
if err := server.Shutdown(ctx); err != nil {
logger.Info().
Err(err).
Str("server", c.Command.Name+"-debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("server", c.Command.Name+"-debug").
Msg("Shutting down server")
}
gr.Add(server.ListenAndServe, func(_ error) {
cancel()
})
}
{
stop := make(chan os.Signal, 1)
gr.Add(func() error {
signal.Notify(stop, os.Interrupt)
<-stop
return nil
}, func(err error) {
close(stop)
cancel()
})
if !cfg.Reva.StorageMetadata.Supervised {
sync.Trap(&gr, cancel)
}
return gr.Run()
@@ -216,6 +189,9 @@ type SharingSutureService struct {
func NewSharing(ctx context.Context, cfg *ociscfg.Config) suture.Service {
sctx, cancel := context.WithCancel(ctx)
cfg.Storage.Reva.Sharing.Context = sctx
if cfg.Mode == 0 {
cfg.Storage.Reva.Sharing.Supervised = true
}
return SharingSutureService{
ctx: sctx,
cancel: cancel,