func (this *Start) shutdown() { // kill haproxy log.Info("killling haproxy processes") f, e := os.Open(haproxyPidFile) if e != nil { log.Error("shutdown %v", e) return } reader := bufio.NewReader(f) for { l, e := gio.ReadLine(reader) if e != nil { // EOF break } pid, _ := strconv.Atoi(string(l)) p := &os.Process{ Pid: pid, } if err := p.Kill(); err != nil { log.Error(err) } else { log.Info("haproxy[%d] terminated", pid) } } log.Info("removing %s", haproxyPidFile) os.Remove(haproxyPidFile) }
func mockEvents() { f, _ := os.Open(mockFile) reader := bufio.NewReader(f) for { l, e := gio.ReadLine(reader) if e != nil { // EOF break } events = append(events, decode(l)) } time.Sleep(time.Second) close(ready) }