From 4ee52cc9cde5fb95649d9d1f4c094c351f16b114 Mon Sep 17 00:00:00 2001 From: "A.Unger" Date: Wed, 10 Mar 2021 16:35:11 +0100 Subject: [PATCH] copy config, since it is shared --- ocis/go.mod | 1 + ocis/pkg/runtime/service/service.go | 11 ++++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/ocis/go.mod b/ocis/go.mod index 424238825..bad1c6426 100644 --- a/ocis/go.mod +++ b/ocis/go.mod @@ -10,6 +10,7 @@ require ( github.com/asim/go-micro/v3 v3.5.1-0.20210217182006-0f0ace1a44a9 github.com/gopherjs/gopherjs v0.0.0-20200217142428-fce0ec30dd00 // indirect github.com/micro/cli/v2 v2.1.2 + github.com/mohae/deepcopy v0.0.0-20170929034955-c48cc78d4826 github.com/olekukonko/tablewriter v0.0.5 github.com/openzipkin/zipkin-go v0.2.5 github.com/owncloud/ocis-hello v0.1.0-alpha1.0.20210204050952-c291e4c5b73f diff --git a/ocis/pkg/runtime/service/service.go b/ocis/pkg/runtime/service/service.go index 48e3c03cb..0b9db575f 100644 --- a/ocis/pkg/runtime/service/service.go +++ b/ocis/pkg/runtime/service/service.go @@ -13,6 +13,8 @@ import ( "syscall" "time" + "github.com/mohae/deepcopy" + mzlog "github.com/asim/go-micro/plugins/logger/zerolog/v3" accounts "github.com/owncloud/ocis/accounts/pkg/command" ocs "github.com/owncloud/ocis/ocs/pkg/command" @@ -165,7 +167,8 @@ func Start(o ...Option) error { }() for name := range s.ServicesRegistry { - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, s.cfg))) + swap := deepcopy.Copy(s.cfg) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, swap.(*ociscfg.Config)))) } go s.Supervisor.ServeBackground() @@ -176,7 +179,8 @@ func Start(o ...Option) error { time.Sleep(2 * time.Second) // add delayed for name := range s.Delayed { - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](s.context, s.cfg))) + swap := deepcopy.Copy(s.cfg) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.Delayed[name](s.context, swap.(*ociscfg.Config)))) } return http.Serve(l, nil) @@ -188,7 +192,8 @@ func (s *Service) Start(name string, reply *int) error { *reply = 1 return nil } - s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, s.cfg))) + swap := deepcopy.Copy(s.cfg) + s.serviceToken[name] = append(s.serviceToken[name], s.Supervisor.Add(s.ServicesRegistry[name](s.context, swap.(*ociscfg.Config)))) *reply = 0 return nil }