func main() { flag.Parse() listenAddr := fmt.Sprintf("%s:%d", *listenip, *port) l.Print("Starting.") conn, err := net.ListenPacket("udp", listenAddr) if err != nil { l.Fatalf("Error opening listen socket: %v\n %v", listenAddr, err) } l.Print("listening on: ", conn.LocalAddr()) var st store.UpdateStore st = memstore.NewMemoryStore() updates := make(chan version.Version) ss := storeServer{st, updates, *danger} go processUpdates(updates, st) go handleUpdateUDP(conn, updates) go trimWorker(*trim, st) apiRoot := http.StripPrefix("/api/v1/", ss) http.Handle("/api/v1/", apiRoot) err = http.ListenAndServe(listenAddr, nil) if err != nil { l.Fatal("ListenAndServe: ", err) } l.Print("Exit.") }
func init() { s = memstore.NewMemoryStore() }