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

View File

@@ -118,6 +118,9 @@ type SutureService struct {
func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service {
sctx, cancel := context.WithCancel(ctx)
cfg.Thumbnails.Context = sctx
if cfg.Mode == 0 {
cfg.Thumbnails.Supervised = true
}
return SutureService{
ctx: sctx,
cancel: cancel,

View File

@@ -3,10 +3,10 @@ package command
import (
"context"
"fmt"
"os"
"os/signal"
"time"
"github.com/owncloud/ocis/ocis-pkg/sync"
"contrib.go.opencensus.io/exporter/jaeger"
"contrib.go.opencensus.io/exporter/ocagent"
"contrib.go.opencensus.io/exporter/zipkin"
@@ -124,8 +124,13 @@ func Server(cfg *config.Config) *cli.Command {
var (
gr = run.Group{}
ctx, cancel = context.WithCancel(context.Background())
metrics = metrics.New()
ctx, cancel = func() (context.Context, context.CancelFunc) {
if cfg.Context == nil {
return context.WithCancel(context.Background())
}
return context.WithCancel(cfg.Context)
}()
metrics = metrics.New()
)
defer cancel()
@@ -140,7 +145,6 @@ func Server(cfg *config.Config) *cli.Command {
grpc.Namespace(cfg.Server.Namespace),
grpc.Address(cfg.Server.Address),
grpc.Metrics(metrics),
//grpc.Flags(flagset.RootWithConfig(config.New())),
)
gr.Add(func() error {
@@ -167,36 +171,11 @@ func Server(cfg *config.Config) *cli.Command {
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("transport", "debug").
Msg("Failed to shutdown server")
} else {
logger.Info().
Str("transport", "debug").
Msg("Shutting down server")
}
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.Supervised {
sync.Trap(&gr, cancel)
}
return gr.Run()

View File

@@ -43,7 +43,8 @@ type Config struct {
Tracing Tracing
Thumbnail Thumbnail
Context context.Context
Context context.Context
Supervised bool
}
// FileSystemStorage defines the available filesystem storage configuration.