func serve(net, ip, port string) { logger := slappy.Logger() bind := fmt.Sprintf("%s:%s", ip, port) server := &dns.Server{Addr: bind, Net: net} dns.HandleFunc(".", slappy.Handle) logger.Info(fmt.Sprintf("slappy starting %s listener on %s", net, bind)) err := server.ListenAndServe() if err != nil { panic(fmt.Sprintf("Failed to set up the "+net+"server %s", err.Error())) } }
func listen() { logger := slappy.Logger() siq_quit := make(chan os.Signal) signal.Notify(siq_quit, syscall.SIGINT, syscall.SIGTERM) sig_stat := make(chan os.Signal) signal.Notify(sig_stat, syscall.SIGUSR1) forever: for { select { case s := <-siq_quit: logger.Info(fmt.Sprintf("Signal (%d) received, stopping", s)) break forever case _ = <-sig_stat: logger.Info(fmt.Sprintf("Goroutines: %d", runtime.NumGoroutine())) } } }