diff --git a/client/deploy_test.go b/client/deploy_test.go index 9e333d1..0fd711a 100644 --- a/client/deploy_test.go +++ b/client/deploy_test.go @@ -5,23 +5,9 @@ import ( "testing" ) -func pof2(x int64) (out int64) { - out = 1 - org := x - for (x >> 1) > 0 { - out = out << 1 - x = x >> 1 - } - if org > out { - out = out << 1 - } - - return -} - func TestDownload(t *testing.T) { //download(".", "https://kdcc.action2quare.com/houston/_deploys/game/0.18.186.1/game.zip", "", nil) - fmt.Println(pof2(1023)) - fmt.Println(pof2(1024)) - fmt.Println(pof2(1025)) + fmt.Println(pof2(1023, 1024)) + fmt.Println(pof2(1024, 1024)) + fmt.Println(pof2(1025, 1024)) } diff --git a/server/http_api.go b/server/http_api.go index 142f4fb..46192f4 100644 --- a/server/http_api.go +++ b/server/http_api.go @@ -517,3 +517,7 @@ func (h *houstonHandler) GetLogFileLinks(w http.ResponseWriter, r *http.Request) enc := json.NewEncoder(w) enc.Encode(out) } + +func (h *houstonHandler) GetDeployingProgress(w http.ResponseWriter, r *http.Request) { + json.NewEncoder(w).Encode(h.Operation().DeplyingProgress()) +} diff --git a/server/operation.go b/server/operation.go index 31c603e..b19b29f 100644 --- a/server/operation.go +++ b/server/operation.go @@ -418,6 +418,10 @@ func (os *operationServer) Hosts() map[string]hostSnapshot { return os.hp.allHosts() } +func (os *operationServer) DeplyingProgress() []*protos.DeployingProgress { + return os.db.clone() +} + func newOperationServer() *operationServer { return &operationServer{ hp: hostPool{ diff --git a/server/server.go b/server/server.go index e46b8f6..b10fc84 100644 --- a/server/server.go +++ b/server/server.go @@ -108,6 +108,7 @@ type Operation interface { RestartProcess(RestartProcessRequest) Upload(UploadRequest) Hosts() map[string]hostSnapshot + DeplyingProgress() []*protos.DeployingProgress } func loadServerConfig() serverConfig {