From 7109d6d635709d56a659ba7ce68fcbb9b8a3c42f Mon Sep 17 00:00:00 2001 From: Kevin Wan Date: Sun, 24 Oct 2021 12:01:17 +0800 Subject: [PATCH] chore: reverse the order of stopping services (#1159) * chore: reverse the order of stopping services * chore: reverse the order of stopping services --- core/service/servicegroup.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/core/service/servicegroup.go b/core/service/servicegroup.go index 4585bf08..984a0eff 100644 --- a/core/service/servicegroup.go +++ b/core/service/servicegroup.go @@ -26,6 +26,7 @@ type ( } // A ServiceGroup is a group of services. + // Attention: the starting order of the added services is not guaranteed. ServiceGroup struct { services []Service stopOnce func() @@ -41,7 +42,8 @@ func NewServiceGroup() *ServiceGroup { // Add adds service into sg. func (sg *ServiceGroup) Add(service Service) { - sg.services = append(sg.services, service) + // push front, stop with reverse order. + sg.services = append([]Service{service}, sg.services...) } // Start starts the ServiceGroup.