From 92c5bf5b46357c2ff228bfff3da7401f416e1389 Mon Sep 17 00:00:00 2001 From: mountain Date: Wed, 28 Jun 2023 15:17:11 +0900 Subject: [PATCH] =?UTF-8?q?=EC=84=9C=EB=B9=84=EC=8A=A4=20=EC=97=85?= =?UTF-8?q?=EB=8D=B0=EC=9D=B4=ED=8A=B8=20=EB=A1=9C=EC=A7=81=20=EC=88=98?= =?UTF-8?q?=EC=A0=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/watch.go | 30 +----------------------------- 1 file changed, 1 insertion(+), 29 deletions(-) diff --git a/core/watch.go b/core/watch.go index 5da350e..42b23cc 100644 --- a/core/watch.go +++ b/core/watch.go @@ -1,10 +1,8 @@ package core import ( - "bytes" "context" "encoding/hex" - "encoding/json" "net/http" "os" "path" @@ -300,33 +298,7 @@ func (mg *Maingate) watchServiceCollection(parentctx context.Context, serveMux * case "update": data.Service.prepare(mg) - old := mg.service() - - atomic.SwapPointer(&old.divisionsForUsersSerialized, data.Service.divisionsForUsersSerialized) - atomic.SwapPointer(&old.divisionsSerialized, data.Service.divisionsSerialized) - atomic.SwapPointer(&old.admins, data.Service.admins) - atomic.SwapPointer(&old.serviceSerialized, data.Service.serviceSerialized) - atomic.SwapPointer(&old.serviceSummarySerialized, data.Service.serviceSummarySerialized) - atomic.SwapPointer(&old.wl.emailptr, data.Service.wl.emailptr) - - old.Divisions = data.Service.Divisions - for _, div := range old.Divisions { - var req *http.Request - if div.State == DivisionState_FullOpen { - req, _ = http.NewRequest("POST", div.Url+"/maingate", nil) - } else if div.Maintenance != nil { - bt, _ := json.Marshal(div.Maintenance) - req, _ = http.NewRequest("POST", div.Url+"/maingate", bytes.NewBuffer(bt)) - } - - if req != nil { - // MG-X-API-TOKEN - req.Header.Add("MG-X-API-TOKEN", old.ServerApiTokens[0].Hex()) - if resp, err := http.DefaultClient.Do(req); err == nil { - resp.Body.Close() - } - } - } + atomic.StorePointer(&mg.serviceptr, unsafe.Pointer(data.Service)) } } else { logger.Error("watchServiceCollection stream.Decode failed :", err)