Пример #1
0
func (e *DeletePortExecutor) Execute(t *Task) (err error) {
	if e.arg.Port == 0 {
		return errors.New("Please specify a port")
	}
	helper.SetRouterRoot(e.arg.Internal)
	err = routerzk.DelPort(datamodel.Zk.Conn, e.arg.Port)
	return err
}
Пример #2
0
func DeletePort(name string) error {
	if name == "" {
		return errors.New("Please specify a port")
	}

	pUint, err := strconv.ParseUint(name, 10, 16)

	if err != nil {
		return err
	}

	return routerzk.DelPort(zkConn.Conn, uint16(pUint))
}
Пример #3
0
func ReclaimRouterPortsForEnv(internal bool, env string) error {
	helper.SetRouterRoot(internal)
	lock := NewRouterPortsLock(internal)
	lock.Lock()
	defer lock.Unlock()
	zrp := GetRouterPorts(internal)
	ports, err := zrp.reclaimEnv(env)
	if err != nil {
		return err
	}
	for _, port := range ports {
		if err := routerzk.DelPort(Zk.Conn, port); err != nil {
			log.Printf("Error reclaiming port %d for env %s", port, env)
			// don't fail here
			// TODO email appsplat
		}
	}
	return nil
}