mirror of
https://github.com/opencloud-eu/opencloud.git
synced 2026-01-04 03:09:33 -06:00
Merge pull request #2843 from owncloud/runtime-supervisor-fixes
[Runtime] Removed trap goroutine in favor of context propagation cancelation
This commit is contained in:
@@ -6,8 +6,6 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/accounts/pkg/config"
|
||||
"github.com/owncloud/ocis/accounts/pkg/metrics"
|
||||
@@ -85,10 +83,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
cancel()
|
||||
})
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
5
changelog/unreleased/supervisor-stop-routine.md
Normal file
5
changelog/unreleased/supervisor-stop-routine.md
Normal file
@@ -0,0 +1,5 @@
|
||||
Enhancement: Correct shutdown of services under runtime
|
||||
|
||||
Supervised goroutines now shut themselves down on context cancellation propagation.
|
||||
|
||||
https://github.com/owncloud/ocis/pull/2843
|
||||
@@ -14,7 +14,6 @@ import (
|
||||
"github.com/owncloud/ocis/glauth/pkg/tracing"
|
||||
pkgcrypto "github.com/owncloud/ocis/ocis-pkg/crypto"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -178,10 +177,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/owncloud/ocis/graph-explorer/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/graph-explorer/pkg/server/http"
|
||||
"github.com/owncloud/ocis/graph-explorer/pkg/tracing"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -95,10 +94,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/owncloud/ocis/graph/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/graph/pkg/server/http"
|
||||
"github.com/owncloud/ocis/graph/pkg/tracing"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -92,10 +91,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -10,7 +10,6 @@ import (
|
||||
"github.com/owncloud/ocis/idp/pkg/server/debug"
|
||||
"github.com/owncloud/ocis/idp/pkg/server/http"
|
||||
"github.com/owncloud/ocis/idp/pkg/tracing"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/urfave/cli/v2"
|
||||
)
|
||||
|
||||
@@ -96,10 +95,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -13,7 +13,6 @@ func StorageMetadataCommand(cfg *config.Config) *cli.Command {
|
||||
Name: "storage-metadata",
|
||||
Usage: "Start storage and data service for metadata",
|
||||
Category: "Extensions",
|
||||
//Flags: flagset.StorageMetadata(cfg.Storage),
|
||||
Before: func(ctx *cli.Context) error {
|
||||
return ParseStorageCommon(ctx, cfg)
|
||||
},
|
||||
|
||||
@@ -22,7 +22,8 @@ func Run(cfg *config.Config) *cobra.Command {
|
||||
log.Fatal("dialing:", err)
|
||||
}
|
||||
var res int
|
||||
if err := client.Call("Service.Start", &args[0], &res); err != nil {
|
||||
|
||||
if err = client.Call("Service.Start", &args[0], &res); err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
|
||||
@@ -137,9 +137,6 @@ func Start(o ...Option) error {
|
||||
halt := make(chan os.Signal, 1)
|
||||
signal.Notify(halt, syscall.SIGINT, syscall.SIGTERM, syscall.SIGQUIT, syscall.SIGHUP)
|
||||
|
||||
// notify goroutines that they are running on supervised mode
|
||||
s.cfg.Mode = ociscfg.SUPERVISED
|
||||
|
||||
setMicroLogger()
|
||||
|
||||
// tolerance controls backoff cycles from the supervisor.
|
||||
@@ -191,7 +188,7 @@ func Start(o ...Option) error {
|
||||
defer func() {
|
||||
if r := recover(); r != nil {
|
||||
reason := strings.Builder{}
|
||||
if _, err := net.Dial("tcp", net.JoinHostPort(s.cfg.Runtime.Host, s.cfg.Runtime.Port)); err != nil {
|
||||
if _, err = net.Dial("tcp", net.JoinHostPort(s.cfg.Runtime.Host, s.cfg.Runtime.Port)); err != nil {
|
||||
reason.WriteString("runtime address already in use")
|
||||
}
|
||||
|
||||
@@ -256,11 +253,6 @@ func (s *Service) generateRunSet(cfg *config.Config) {
|
||||
|
||||
// Start indicates the Service Controller to start a new supervised service as an OS thread.
|
||||
func (s *Service) Start(name string, reply *int) error {
|
||||
// RPC calls to a Service object will allow for parsing config. Mind that since the runtime is running on a different
|
||||
// machine, the configuration needs to be present in the given machine. RPC does not yet allow providing a config
|
||||
// during transport.
|
||||
s.cfg.Mode = ociscfg.UNSUPERVISED
|
||||
|
||||
swap := deepcopy.Copy(s.cfg)
|
||||
if _, ok := s.ServicesRegistry[name]; ok {
|
||||
*reply = 0
|
||||
@@ -306,7 +298,7 @@ func (s *Service) List(args struct{}, reply *string) error {
|
||||
func (s *Service) Kill(name string, reply *int) error {
|
||||
if len(s.serviceToken[name]) > 0 {
|
||||
for i := range s.serviceToken[name] {
|
||||
if err := s.Supervisor.Remove(s.serviceToken[name][i]); err != nil {
|
||||
if err := s.Supervisor.RemoveAndWait(s.serviceToken[name][i], 5000*time.Millisecond); err != nil {
|
||||
return err
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,8 +6,6 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/ocs/pkg/tracing"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/ocs/pkg/config"
|
||||
"github.com/owncloud/ocis/ocs/pkg/metrics"
|
||||
@@ -100,10 +98,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ import (
|
||||
"github.com/owncloud/ocis/ocis-pkg/log"
|
||||
pkgmiddleware "github.com/owncloud/ocis/ocis-pkg/middleware"
|
||||
"github.com/owncloud/ocis/ocis-pkg/service/grpc"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/proxy/pkg/config"
|
||||
"github.com/owncloud/ocis/proxy/pkg/cs3"
|
||||
"github.com/owncloud/ocis/proxy/pkg/metrics"
|
||||
@@ -138,10 +137,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/settings/pkg/config"
|
||||
"github.com/owncloud/ocis/settings/pkg/metrics"
|
||||
"github.com/owncloud/ocis/settings/pkg/server/debug"
|
||||
@@ -83,10 +82,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
cancel()
|
||||
})
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&servers, cancel)
|
||||
}
|
||||
|
||||
return servers.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -9,8 +9,6 @@ import (
|
||||
|
||||
"github.com/owncloud/ocis/store/pkg/tracing"
|
||||
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/store/pkg/config"
|
||||
"github.com/owncloud/ocis/store/pkg/metrics"
|
||||
@@ -103,10 +101,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"fmt"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/config"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/metrics"
|
||||
"github.com/owncloud/ocis/thumbnails/pkg/server/debug"
|
||||
@@ -78,10 +77,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
cancel()
|
||||
})
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -7,7 +7,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/web/pkg/config"
|
||||
"github.com/owncloud/ocis/web/pkg/metrics"
|
||||
"github.com/owncloud/ocis/web/pkg/server/debug"
|
||||
@@ -124,10 +123,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
@@ -5,7 +5,6 @@ import (
|
||||
"strings"
|
||||
|
||||
"github.com/oklog/run"
|
||||
"github.com/owncloud/ocis/ocis-pkg/sync"
|
||||
"github.com/owncloud/ocis/webdav/pkg/config"
|
||||
"github.com/owncloud/ocis/webdav/pkg/metrics"
|
||||
"github.com/owncloud/ocis/webdav/pkg/server/debug"
|
||||
@@ -100,10 +99,6 @@ func Server(cfg *config.Config) *cli.Command {
|
||||
})
|
||||
}
|
||||
|
||||
if !cfg.Supervised {
|
||||
sync.Trap(&gr, cancel)
|
||||
}
|
||||
|
||||
return gr.Run()
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user