mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-04-23 20:49:13 -05:00
update commands when running in supervised mode
This commit is contained in:
@@ -7,13 +7,13 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/accounts/pkg/flagset"
|
||||
|
||||
"github.com/thejerf/suture"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/micro/cli/v2"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/version"
|
||||
ociscfg "github.com/owncloud/ocis/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
"github.com/spf13/viper"
|
||||
"github.com/thejerf/suture"
|
||||
)
|
||||
|
||||
var (
|
||||
@@ -132,6 +132,9 @@ type SutureService struct {
|
||||
func NewSutureService(ctx context.Context, cfg *ociscfg.Config) suture.Service {
|
||||
sctx, cancel := context.WithCancel(ctx)
|
||||
cfg.Accounts.Context = sctx // propagate the context down to the go-micro services.
|
||||
if cfg.Mode == 0 {
|
||||
cfg.Accounts.Supervised = true
|
||||
}
|
||||
return SutureService{
|
||||
ctx: sctx,
|
||||
cancel: cancel,
|
||||
|
||||
@@ -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"
|
||||
@@ -140,10 +140,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
)
|
||||
|
||||
gr.Add(server.Run, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", "http").
|
||||
Msg("Shutting down server")
|
||||
|
||||
logger.Info().Str("server", "http").Msg("Shutting down server")
|
||||
cancel()
|
||||
})
|
||||
}
|
||||
@@ -158,30 +155,14 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
grpc.Handler(handler),
|
||||
)
|
||||
|
||||
gr.Add(func() error {
|
||||
return server.Run()
|
||||
}, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", "grpc").
|
||||
Msg("Shutting down server")
|
||||
|
||||
gr.Add(server.Run, func(_ error) {
|
||||
logger.Info().Str("server", "grpc").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()
|
||||
|
||||
Reference in New Issue
Block a user