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

@@ -2,11 +2,11 @@ package command
import (
"context"
"os"
"os/signal"
"strings"
"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"
@@ -146,8 +146,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()
@@ -219,19 +224,8 @@ func Server(cfg *config.Config) *cli.Command {
})
}
{
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()