Merge pull request #9656 from owncloud/reuse-node-id
reuse node id when registering services
This commit is contained in:
@@ -2,6 +2,7 @@ Bugfix: Repair nats-js-kv registry
|
||||
|
||||
The registry would always send traffic to only one pod. This is now fixed and load should be spread evenly. Also implements watcher method so the cache can use it.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/9656
|
||||
https://github.com/owncloud/ocis/pull/9662
|
||||
https://github.com/owncloud/ocis/pull/9654
|
||||
https://github.com/owncloud/ocis/pull/9620
|
||||
|
||||
@@ -361,7 +361,7 @@ replace github.com/egirna/icap-client => github.com/fschade/icap-client v0.0.0-2
|
||||
|
||||
replace github.com/unrolled/secure => github.com/DeepDiver1975/secure v0.0.0-20240611112133-abc838fb797c
|
||||
|
||||
replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73
|
||||
replace github.com/go-micro/plugins/v4/store/nats-js-kv => github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6
|
||||
|
||||
// exclude the v2 line of go-sqlite3 which was released accidentally and prevents pulling in newer versions of go-sqlite3
|
||||
// see https://github.com/mattn/go-sqlite3/issues/965 for more details
|
||||
|
||||
@@ -1609,8 +1609,8 @@ github.com/klauspost/cpuid/v2 v2.0.1/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa02
|
||||
github.com/klauspost/cpuid/v2 v2.0.9/go.mod h1:FInQzS24/EEf25PyTYn52gqo7WaD8xa0213Md/qVLRg=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6 h1:ndNyv040zDGIDh8thGkXYjnFtiN02M1PVVF+JE/48xc=
|
||||
github.com/klauspost/cpuid/v2 v2.2.6/go.mod h1:Lcz8mBdAVJIBVzewtcLocK12l3Y+JytZYpaMropDUws=
|
||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73 h1:Cgg5BVWG99INUMX43nD5jhZgNzQJyFA0MvZkctNn0Lw=
|
||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240723073728-b36ea3314b73/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY=
|
||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6 h1:NNXx1/XWR6Ryud6qNanwrl/JuRx2KdCW1jS2/Cf/TO8=
|
||||
github.com/kobergj/plugins/v4/store/nats-js-kv v0.0.0-20240724102745-4bc93ffd7ab6/go.mod h1:pjcozWijkNPbEtX5SIQaxEW/h8VAVZYTLx+70bmB3LY=
|
||||
github.com/kolo/xmlrpc v0.0.0-20200310150728-e0350524596b/go.mod h1:o03bZfuBwAXHetKXuInt4S7omeXUu62/A845kiycsSQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
github.com/konsorten/go-windows-terminal-sequences v1.0.2/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ=
|
||||
|
||||
@@ -12,9 +12,9 @@ import (
|
||||
"time"
|
||||
|
||||
natsjskv "github.com/go-micro/plugins/v4/store/nats-js-kv"
|
||||
"github.com/google/uuid"
|
||||
"github.com/nats-io/nats.go"
|
||||
"go-micro.dev/v4/registry"
|
||||
"go-micro.dev/v4/server"
|
||||
"go-micro.dev/v4/store"
|
||||
"go-micro.dev/v4/util/cmd"
|
||||
)
|
||||
@@ -25,7 +25,7 @@ var (
|
||||
_registryUsernameEnv = "MICRO_REGISTRY_AUTH_USERNAME"
|
||||
_registryPasswordEnv = "MICRO_REGISTRY_AUTH_PASSWORD"
|
||||
|
||||
_serviceDelimiter = "/"
|
||||
_serviceDelimiter = "@"
|
||||
)
|
||||
|
||||
func init() {
|
||||
@@ -90,18 +90,12 @@ func (n *storeregistry) Register(s *registry.Service, opts ...registry.RegisterO
|
||||
o(&options)
|
||||
}
|
||||
|
||||
unique := uuid.New().String()
|
||||
if s.Metadata == nil {
|
||||
s.Metadata = make(map[string]string)
|
||||
}
|
||||
s.Metadata["uuid"] = unique
|
||||
|
||||
b, err := json.Marshal(s)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
return n.store.Write(&store.Record{
|
||||
Key: s.Name + _serviceDelimiter + unique,
|
||||
Key: s.Name + _serviceDelimiter + server.DefaultId,
|
||||
Value: b,
|
||||
Expiry: options.TTL,
|
||||
})
|
||||
@@ -111,13 +105,7 @@ func (n *storeregistry) Register(s *registry.Service, opts ...registry.RegisterO
|
||||
func (n *storeregistry) Deregister(s *registry.Service, _ ...registry.DeregisterOption) error {
|
||||
n.lock.RLock()
|
||||
defer n.lock.RUnlock()
|
||||
|
||||
var unique string
|
||||
if s.Metadata != nil {
|
||||
unique = s.Metadata["uuid"]
|
||||
}
|
||||
|
||||
return n.store.Delete(s.Name + _serviceDelimiter + unique)
|
||||
return n.store.Delete(s.Name + _serviceDelimiter + server.DefaultId)
|
||||
}
|
||||
|
||||
// GetService gets a specific service from the registry
|
||||
|
||||
@@ -1,21 +1,23 @@
|
||||
package natsjsregistry
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
|
||||
natsjskv "github.com/go-micro/plugins/v4/store/nats-js-kv"
|
||||
"github.com/nats-io/nats.go"
|
||||
"go-micro.dev/v4/registry"
|
||||
)
|
||||
|
||||
// NatsWatcher is the watcher of the nats interface
|
||||
type NatsWatcher interface {
|
||||
WatchAll(bucket string, opts ...nats.WatchOpt) (nats.KeyWatcher, error)
|
||||
WatchAll(bucket string, opts ...nats.WatchOpt) (<-chan *natsjskv.StoreUpdate, func() error, error)
|
||||
}
|
||||
|
||||
// Watcher is used to keep track of changes in the registry
|
||||
type Watcher struct {
|
||||
watch nats.KeyWatcher
|
||||
updates <-chan nats.KeyValueEntry
|
||||
updates <-chan *natsjskv.StoreUpdate
|
||||
stop func() error
|
||||
reg *storeregistry
|
||||
}
|
||||
|
||||
@@ -26,14 +28,14 @@ func NewWatcher(s *storeregistry) (*Watcher, error) {
|
||||
return nil, errors.New("store does not implement watcher interface")
|
||||
}
|
||||
|
||||
watcher, err := w.WatchAll("service-registry")
|
||||
watcher, stop, err := w.WatchAll("service-registry")
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
return &Watcher{
|
||||
watch: watcher,
|
||||
updates: watcher.Updates(),
|
||||
updates: watcher,
|
||||
stop: stop,
|
||||
reg: s,
|
||||
}, nil
|
||||
}
|
||||
@@ -45,30 +47,18 @@ func (w *Watcher) Next() (*registry.Result, error) {
|
||||
return nil, errors.New("watcher stopped")
|
||||
}
|
||||
|
||||
service, err := w.reg.getService(kve.Key())
|
||||
if err != nil {
|
||||
var svc *registry.Service
|
||||
if err := json.Unmarshal(kve.Value.Data, svc); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var action string
|
||||
switch kve.Operation() {
|
||||
default:
|
||||
action = "create"
|
||||
case nats.KeyValuePut:
|
||||
action = "create"
|
||||
case nats.KeyValueDelete:
|
||||
action = "delete"
|
||||
case nats.KeyValuePurge:
|
||||
action = "delete"
|
||||
}
|
||||
|
||||
return ®istry.Result{
|
||||
Service: service,
|
||||
Action: action,
|
||||
Service: svc,
|
||||
Action: kve.Action,
|
||||
}, nil
|
||||
}
|
||||
|
||||
// Stop stops the watcher
|
||||
func (w *Watcher) Stop() {
|
||||
_ = w.watch.Stop()
|
||||
_ = w.stop()
|
||||
}
|
||||
|
||||
@@ -7,10 +7,11 @@ import (
|
||||
"strings"
|
||||
|
||||
mRegistry "go-micro.dev/v4/registry"
|
||||
"go-micro.dev/v4/server"
|
||||
"go-micro.dev/v4/util/addr"
|
||||
)
|
||||
|
||||
func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistry.Service {
|
||||
func BuildGRPCService(serviceID, address string, version string) *mRegistry.Service {
|
||||
var host string
|
||||
var port int
|
||||
|
||||
@@ -28,7 +29,7 @@ func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistr
|
||||
}
|
||||
|
||||
node := &mRegistry.Node{
|
||||
Id: serviceID + "-" + uuid,
|
||||
Id: serviceID + "-" + server.DefaultId,
|
||||
Address: net.JoinHostPort(addr, fmt.Sprint(port)),
|
||||
Metadata: make(map[string]string),
|
||||
}
|
||||
@@ -46,7 +47,7 @@ func BuildGRPCService(serviceID, uuid, address string, version string) *mRegistr
|
||||
}
|
||||
}
|
||||
|
||||
func BuildHTTPService(serviceID, uuid, address string, version string) *mRegistry.Service {
|
||||
func BuildHTTPService(serviceID, address string, version string) *mRegistry.Service {
|
||||
var host string
|
||||
var port int
|
||||
|
||||
@@ -64,7 +65,7 @@ func BuildHTTPService(serviceID, uuid, address string, version string) *mRegistr
|
||||
}
|
||||
|
||||
node := &mRegistry.Node{
|
||||
Id: serviceID + "-" + uuid,
|
||||
Id: serviceID + "-" + server.DefaultId,
|
||||
Address: net.JoinHostPort(addr, fmt.Sprint(port)),
|
||||
Metadata: make(map[string]string),
|
||||
}
|
||||
|
||||
@@ -25,6 +25,7 @@ func NewServiceWithClient(client client.Client, opts ...Option) (Service, error)
|
||||
var mServer server.Server
|
||||
sopts := newOptions(opts...)
|
||||
tlsConfig := &tls.Config{}
|
||||
|
||||
if sopts.TLSEnabled {
|
||||
var cert tls.Certificate
|
||||
var err error
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
package command
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/clihelper"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config"
|
||||
@@ -25,5 +28,6 @@ func Execute() error {
|
||||
)
|
||||
}
|
||||
|
||||
return app.Run(os.Args)
|
||||
ctx, _ := signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
return app.RunContext(ctx, os.Args)
|
||||
}
|
||||
|
||||
@@ -21,7 +21,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Action: func(c *cli.Context) error {
|
||||
// Prefer the in-memory registry as the default when running in single-binary mode
|
||||
r := runtime.New(cfg)
|
||||
return r.Start()
|
||||
return r.Start(c.Context)
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
package runtime
|
||||
|
||||
import (
|
||||
"context"
|
||||
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config"
|
||||
"github.com/owncloud/ocis/v2/ocis/pkg/runtime/service"
|
||||
)
|
||||
@@ -18,6 +20,6 @@ func New(cfg *config.Config) Runtime {
|
||||
}
|
||||
|
||||
// Start rpc runtime
|
||||
func (r *Runtime) Start() error {
|
||||
return service.Start(service.WithConfig(r.c))
|
||||
func (r *Runtime) Start(ctx context.Context) error {
|
||||
return service.Start(ctx, service.WithConfig(r.c))
|
||||
}
|
||||
|
||||
@@ -7,10 +7,8 @@ import (
|
||||
"net/http"
|
||||
"net/rpc"
|
||||
"os"
|
||||
"os/signal"
|
||||
"sort"
|
||||
"strings"
|
||||
"syscall"
|
||||
"time"
|
||||
|
||||
authapp "github.com/owncloud/ocis/v2/services/auth-app/pkg/command"
|
||||
@@ -96,7 +94,7 @@ type Service struct {
|
||||
// calls are done explicitly to loadFromEnv().
|
||||
// Since this is the public constructor, options need to be added, at the moment only logging options
|
||||
// are supported in order to match the running OwnCloud services structured log.
|
||||
func NewService(options ...Option) (*Service, error) {
|
||||
func NewService(ctx context.Context, options ...Option) (*Service, error) {
|
||||
opts := NewOptions()
|
||||
|
||||
for _, f := range options {
|
||||
@@ -109,7 +107,7 @@ func NewService(options ...Option) (*Service, error) {
|
||||
log.Level(opts.Config.Log.Level),
|
||||
)
|
||||
|
||||
globalCtx, cancelGlobal := context.WithCancel(context.Background())
|
||||
globalCtx, cancelGlobal := context.WithCancel(ctx)
|
||||
|
||||
s := &Service{
|
||||
Services: make([]serviceFuncMap, len(_waitFuncs)),
|
||||
@@ -352,19 +350,18 @@ func NewService(options ...Option) (*Service, error) {
|
||||
|
||||
// Start a rpc service. By default, the package scope Start will run all default services to provide with a working
|
||||
// oCIS instance.
|
||||
func Start(o ...Option) error {
|
||||
func Start(ctx context.Context, o ...Option) error {
|
||||
// Start the runtime. Most likely this was called ONLY by the `ocis server` subcommand, but since we cannot protect
|
||||
// from the caller, the previous statement holds truth.
|
||||
|
||||
// prepare a new rpc Service struct.
|
||||
s, err := NewService(o...)
|
||||
s, err := NewService(ctx, o...)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
// halt listens for interrupt signals and blocks.
|
||||
halt := make(chan os.Signal, 1)
|
||||
signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
// get a cancel function to stop the service
|
||||
ctx, cancel := context.WithCancel(ctx)
|
||||
|
||||
// tolerance controls backoff cycles from the supervisor.
|
||||
tolerance := 5
|
||||
@@ -376,7 +373,7 @@ func Start(o ...Option) error {
|
||||
if e.Type() == suture.EventTypeBackoff {
|
||||
totalBackoff++
|
||||
if totalBackoff == tolerance {
|
||||
halt <- os.Interrupt
|
||||
cancel()
|
||||
}
|
||||
}
|
||||
s.Log.Info().Str("event", e.String()).Msg(fmt.Sprintf("supervisor: %v", e.Map()["supervisor_name"]))
|
||||
@@ -424,8 +421,8 @@ func Start(o ...Option) error {
|
||||
// https://pkg.go.dev/github.com/thejerf/suture/v4@v4.0.0#Supervisor
|
||||
go s.Supervisor.ServeBackground(s.context)
|
||||
|
||||
// trap will block on halt channel for interruptions.
|
||||
go trap(s, halt)
|
||||
// trap will block on context done channel for interruptions.
|
||||
go trap(s, ctx)
|
||||
|
||||
for i, service := range s.Services {
|
||||
scheduleServiceTokens(s, service)
|
||||
@@ -508,9 +505,8 @@ func (s *Service) List(_ struct{}, reply *string) error {
|
||||
|
||||
// trap blocks on halt channel. When the runtime is interrupted it
|
||||
// signals the controller to stop any supervised process.
|
||||
func trap(s *Service, halt chan os.Signal) {
|
||||
<-halt
|
||||
s.cancel()
|
||||
func trap(s *Service, ctx context.Context) {
|
||||
<-ctx.Done()
|
||||
for sName := range s.serviceToken {
|
||||
for i := range s.serviceToken[sName] {
|
||||
if err := s.Supervisor.Remove(s.serviceToken[sName][i]); err != nil {
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/activitylog/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/activitylog/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/cs3org/reva/v2/pkg/events/stream"
|
||||
@@ -61,12 +60,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
mtrcs := metrics.New()
|
||||
mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1)
|
||||
@@ -145,7 +139,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/antivirus/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/antivirus/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -29,13 +29,8 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Action: func(c *cli.Context) error {
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
logger = log.NewLogger(
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
logger = log.NewLogger(
|
||||
log.Name(cfg.Service.Name),
|
||||
log.Level(cfg.Log.Level),
|
||||
log.Pretty(cfg.Log.Pretty),
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/app-provider/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -82,7 +81,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -91,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/app-registry/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/app-registry/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -60,7 +60,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -77,7 +76,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
cancel()
|
||||
})
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -86,14 +85,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/audit/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/audit/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/cs3org/reva/v2/pkg/events/stream"
|
||||
@@ -34,12 +33,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
gr = run.Group{}
|
||||
logger = logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
@@ -60,7 +54,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Err(err).
|
||||
Msg("Shutting down server")
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
{
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/auth-app/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/auth-app/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -31,14 +31,14 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Before: func(_ *cli.Context) error {
|
||||
return configlog.ReturnFatal(parser.ParseConfig(cfg))
|
||||
},
|
||||
Action: func(_ *cli.Context) error {
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -82,7 +81,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -91,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/auth-basic/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/auth-basic/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -74,7 +74,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -95,7 +94,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -104,14 +103,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/auth-bearer/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/auth-bearer/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
// SutureService allows for the accounts command to be embedded and supervised by a suture supervisor tree.
|
||||
|
||||
@@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -82,7 +81,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -91,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/auth-machine/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/auth-machine/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -82,7 +81,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -91,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/auth-service/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/auth-service/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -61,7 +61,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -83,7 +82,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -92,14 +91,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/clientlog/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/clientlog/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/events"
|
||||
"github.com/cs3org/reva/v2/pkg/events/stream"
|
||||
@@ -62,12 +61,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
mtrcs := metrics.New()
|
||||
mtrcs.BuildInfo.WithLabelValues(version.GetString()).Set(1)
|
||||
@@ -118,7 +112,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -25,5 +25,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -36,12 +36,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
defer cancel()
|
||||
|
||||
// prepare components
|
||||
|
||||
@@ -8,7 +8,6 @@ import (
|
||||
gatewayv1beta1 "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
rpcv1beta1 "github.com/cs3org/go-cs3apis/cs3/rpc/v1beta1"
|
||||
"github.com/cs3org/reva/v2/pkg/mime"
|
||||
"github.com/gofrs/uuid"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/log"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/registry"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/version"
|
||||
@@ -19,7 +18,7 @@ import (
|
||||
// There are no explicit requirements for the context, and it will be passed
|
||||
// without changes to the underlying RegisterService method.
|
||||
func RegisterOcisService(ctx context.Context, cfg *config.Config, logger log.Logger) error {
|
||||
svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name+"."+cfg.App.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
svc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name+"."+cfg.App.Name, cfg.GRPC.Addr, version.GetString())
|
||||
return registry.RegisterService(ctx, svc, logger)
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/eventhistory/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/eventhistory/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -47,13 +47,8 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
m = metrics.New()
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
m = metrics.New()
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/frontend/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/frontend/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -65,7 +65,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -86,7 +85,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.HTTP.Addr, version.GetString())
|
||||
httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, cfg.HTTP.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, httpSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the http service")
|
||||
}
|
||||
@@ -102,14 +101,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/gateway/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/gateway/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -37,7 +37,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -51,7 +51,9 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
runtime.WithRegistry(reg),
|
||||
runtime.WithTraceProvider(traceProvider),
|
||||
)
|
||||
|
||||
logger.Info().
|
||||
Str("server", cfg.Service.Name).
|
||||
Msg("reva runtime exited")
|
||||
return nil
|
||||
}, func(err error) {
|
||||
logger.Error().
|
||||
@@ -60,7 +62,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -74,10 +75,13 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr.Add(debugServer.ListenAndServe, func(_ error) {
|
||||
logger.Info().
|
||||
Str("server", cfg.Service.Name).
|
||||
Msg("Shutting down debug erver")
|
||||
cancel()
|
||||
})
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -86,14 +90,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/graph/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Usage: "Serve Graph API for oCIS",
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
@@ -35,12 +34,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
mtrcs := metrics.New()
|
||||
|
||||
defer cancel()
|
||||
@@ -69,7 +63,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func init() {
|
||||
r := registry.GetRegistry(registry.Inmemory())
|
||||
service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "")
|
||||
service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "")
|
||||
service.Nodes = []*mRegistry.Node{{
|
||||
Address: "any",
|
||||
}}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/groups/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/groups/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -74,7 +74,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -95,7 +94,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
@@ -104,14 +103,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/idm/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/idm/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -40,12 +40,7 @@ func ResetPassword(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
return resetPassword(ctx, logger, cfg, c.String("user-name"))
|
||||
|
||||
@@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -40,12 +40,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
var (
|
||||
gr = run.Group{}
|
||||
logger = logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
@@ -95,7 +90,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Err(err).
|
||||
Msg("Shutting down server")
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/idp/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/idp/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -56,13 +56,8 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
}
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
metrics = metrics.New()
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
metrics = metrics.New()
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
@@ -95,7 +90,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/invitations/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/invitations/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
@@ -37,13 +36,8 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
metrics = metrics.New(metrics.Logger(logger))
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
metrics = metrics.New(metrics.Logger(logger))
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
@@ -89,7 +83,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/nats/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/nats/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -4,7 +4,6 @@ import (
|
||||
"context"
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/oklog/run"
|
||||
|
||||
@@ -33,12 +32,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
logger := logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -114,7 +108,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
natsServer.Shutdown()
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
return gr.Run()
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/notifications/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/notifications/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -53,13 +53,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
gr := run.Group{}
|
||||
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
defer cancel()
|
||||
|
||||
{
|
||||
|
||||
@@ -12,7 +12,7 @@ import (
|
||||
|
||||
func init() {
|
||||
r := registry.GetRegistry(registry.Inmemory())
|
||||
service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "", "")
|
||||
service := registry.BuildGRPCService("com.owncloud.api.gateway", "", "")
|
||||
service.Nodes = []*mRegistry.Node{{
|
||||
Address: "any",
|
||||
}}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/ocdav/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/ocdav/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/cs3org/reva/v2/pkg/micro/ocdav"
|
||||
"github.com/cs3org/reva/v2/pkg/sharedconf"
|
||||
@@ -36,7 +35,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -104,7 +103,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Str("server", c.Command.Name).
|
||||
Msg("Shutting down server")
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -127,14 +125,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/ocm/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/ocm/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -38,7 +38,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
return err
|
||||
}
|
||||
gr := run.Group{}
|
||||
ctx, cancel := defineContext(cfg)
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -62,7 +62,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
|
||||
debugServer, err := debug.Server(
|
||||
@@ -83,12 +82,12 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.GRPC.Addr, version.GetString())
|
||||
grpcSvc := registry.BuildGRPCService(cfg.GRPC.Namespace+"."+cfg.Service.Name, cfg.GRPC.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, grpcSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the grpc service")
|
||||
}
|
||||
|
||||
httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, uuid.Must(uuid.NewV4()).String(), cfg.HTTP.Addr, version.GetString())
|
||||
httpSvc := registry.BuildHTTPService(cfg.HTTP.Namespace+"."+cfg.Service.Name, cfg.HTTP.Addr, version.GetString())
|
||||
if err := registry.RegisterService(ctx, httpSvc, logger); err != nil {
|
||||
logger.Fatal().Err(err).Msg("failed to register the http service")
|
||||
}
|
||||
@@ -97,14 +96,3 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
}
|
||||
}
|
||||
|
||||
// defineContext sets the context for the service. If there is a context configured it will create a new child from it,
|
||||
// if not, it will create a root context that can be cancelled.
|
||||
func defineContext(cfg *config.Config) (context.Context, context.CancelFunc) {
|
||||
return func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
}
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/ocs/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/ocs/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@ package command
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/v2/ocis-pkg/config/configlog"
|
||||
@@ -42,13 +41,8 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
metrics = metrics.New()
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
metrics = metrics.New()
|
||||
)
|
||||
|
||||
defer cancel()
|
||||
@@ -82,7 +76,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/policies/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/policies/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -25,5 +25,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -35,13 +35,8 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Action: func(c *cli.Context) error {
|
||||
var (
|
||||
gr = run.Group{}
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
logger = log.NewLogger(
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
logger = log.NewLogger(
|
||||
log.Name(cfg.Service.Name),
|
||||
log.Level(cfg.Log.Level),
|
||||
log.Pretty(cfg.Log.Pretty),
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/postprocessing/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/postprocessing/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -36,15 +36,9 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
},
|
||||
Action: func(c *cli.Context) error {
|
||||
var (
|
||||
gr = run.Group{}
|
||||
logger = logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
|
||||
ctx, cancel = func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
gr = run.Group{}
|
||||
logger = logging.Configure(cfg.Service.Name, cfg.Log)
|
||||
ctx, cancel = context.WithCancel(c.Context)
|
||||
)
|
||||
defer cancel()
|
||||
|
||||
@@ -88,7 +82,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Str("server", "http").
|
||||
Msg("Shutting down server")
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/proxy/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/proxy/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -30,5 +30,5 @@ func Execute(cfg *config.Config) error {
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/http"
|
||||
"os"
|
||||
"time"
|
||||
|
||||
gateway "github.com/cs3org/go-cs3apis/cs3/gateway/v1beta1"
|
||||
@@ -120,12 +119,7 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
m := metrics.New()
|
||||
|
||||
gr := run.Group{}
|
||||
ctx, cancel := func() (context.Context, context.CancelFunc) {
|
||||
if cfg.Context == nil {
|
||||
return context.WithCancel(context.Background())
|
||||
}
|
||||
return context.WithCancel(cfg.Context)
|
||||
}()
|
||||
ctx, cancel := context.WithCancel(c.Context)
|
||||
|
||||
defer cancel()
|
||||
|
||||
@@ -221,7 +215,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
Msg("Shutting down server")
|
||||
|
||||
cancel()
|
||||
os.Exit(1)
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
@@ -1,14 +1,19 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"context"
|
||||
"os"
|
||||
"os/signal"
|
||||
"syscall"
|
||||
|
||||
"github.com/owncloud/ocis/v2/services/search/pkg/command"
|
||||
"github.com/owncloud/ocis/v2/services/search/pkg/config/defaults"
|
||||
)
|
||||
|
||||
func main() {
|
||||
if err := command.Execute(defaults.DefaultConfig()); err != nil {
|
||||
cfg := defaults.DefaultConfig()
|
||||
cfg.Context, _ = signal.NotifyContext(context.Background(), syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
if err := command.Execute(cfg); err != nil {
|
||||
os.Exit(1)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,5 +31,5 @@ func Execute(cfg *config.Config) error {
|
||||
Usage: "Serve search API for oCIS",
|
||||
Commands: GetCommands(cfg),
|
||||
})
|
||||
return app.Run(os.Args)
|
||||
return app.RunContext(cfg.Context, os.Args)
|
||||
}
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user