mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-06 04:09:40 -06:00
update commands when running in supervised mode
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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()
|
||||
|
||||
@@ -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.
|
||||
|
||||
Reference in New Issue
Block a user