Пример #1
0
func (h *RpcServer) DeployStatue(r *http.Request, args *rpc.SimpleArgs, reply *rpc.RpcReply) error {

	c := client.FindFromCache(args.Id)

	c.SetMessage(args.Message)
	webSocket.BroadCastAll(&webSocket.Message{
		Method: "deploy",
		Params: args,
	})

	switch args.What {
	case deployEnum.Error:
		c.SetError(args.Message)
		c.SetMessage()
		c.SetBusy(false)
		break
	case deployEnum.Finish:
		c.SetError()
		c.SetMessage()
		c.SetBusy(false)
		break
	}

	reply.Response = true
	return nil
}
Пример #2
0
func init() {
	task.New("Heartbeat", func(this *task.Task) interface{} {
		Refresh()
		return nil
	})

	updating := false

	task.New("client.UpdateHostUnDeployList", func(this *task.Task) interface{} {

		if updating {
			return nil
		}

		updating = true

		defer func() {
			this.Enable = false
			updating = false
		}()

		webSocket.BroadCastAll(&webSocket.Message{
			Method: "syncDeployList",
		})

		if master.UnDeployList != nil {
			result := map[int64]error{}
			helper.AsyncMap(hostMap, func(key, value interface{}) bool {
				c := value.(*HostClient)
				err := c.UpdateUnDeployList(&master.UnDeployList)
				result[c.Id] = err
				return false
			})
			webSocket.BroadCastAll(&webSocket.Message{
				Method: "syncDeployList",
				Params: result,
			})
		}
		return nil
	})
}
Пример #3
0
func update() (model.Version, error) {
	now := time.Now()
	version := model.Version{}

	num, list, err := svnUp()
	if err != nil {
		return version, err
	}

	if master.IsChanged(num) == false {
		return version, helper.NewError("no change")
	}

	master.Version = num

	version = model.Version{
		Version: num,
		Time:    now,
		List:    JSON.Stringify(list),
	}

	if err := master.UpdateVersion(&version); err != nil {
		return version, err
	}

	master.SetUnDeployFile(list)

	task.Trigger("client.UpdateHostUnDeployList")

	webSocket.BroadCastAll(&webSocket.Message{
		"svnup",
		helper.Success(version),
	})

	return version, nil
}
Пример #4
0
func (h *RpcServer) BroadCastAll(r *http.Request, args *webSocket.Message, reply *rpc.RpcReply) error {
	webSocket.BroadCastAll(args)
	reply.Response = true
	return nil
}