func fixContainer(container *container, ip, port string) error { router, err := getRouter() if err != nil { return err } router.RemoveRoute(container.AppName, container.getAddress()) runCmd("ssh-keygen", "-R", container.Ip) container.Ip = ip container.HostPort = port router.AddRoute(container.AppName, container.getAddress()) return collection().UpdateId(container.Id, container) }
func fixContainer(container *container, ip, port string) error { router, err := getRouter() if err != nil { return err } router.RemoveRoute(container.AppName, container.getAddress()) container.removeHost() container.IP = ip container.HostPort = port router.AddRoute(container.AppName, container.getAddress()) coll := collection() defer coll.Database.Session.Close() return coll.UpdateId(container.ID, container) }
func Example() { router, err := router.Get("hipache") if err != nil { panic(err) } err = router.AddRoute("myapp", "http://10.10.10.10:8080") if err != nil { panic(err) } addr, _ := router.Addr("myapp") fmt.Println("Please access:", addr) err = router.RemoveRoute("myapp") if err != nil { panic(err) } }
func (p *JujuProvisioner) heal(units []provision.Unit) { var inst instance coll := p.unitsCollection() defer coll.Close() for _, unit := range units { err := coll.FindId(unit.Name).One(&inst) if err != nil { coll.Insert(instance{UnitName: unit.Name, InstanceID: unit.InstanceId}) } else if unit.InstanceId == inst.InstanceID { continue } else { format := "[juju] instance-id of unit %q changed from %q to %q. Healing." log.Debugf(format, unit.Name, inst.InstanceID, unit.InstanceId) if p.elbSupport() { router, err := Router() if err != nil { continue } router.RemoveRoute(unit.AppName, inst.InstanceID) err = router.AddRoute(unit.AppName, unit.InstanceId) if err != nil { format := "[juju] Could not register instance %q in the load balancer: %s." log.Errorf(format, unit.InstanceId, err) continue } } if inst.InstanceID != "pending" { msg := queue.Message{ Action: app.RegenerateApprcAndStart, Args: []string{unit.AppName, unit.Name}, } app.Enqueue(msg) } inst.InstanceID = unit.InstanceId coll.UpdateId(unit.Name, inst) } } }