diff --git a/cmd/ximap/ximap.go b/cmd/ximap/ximap.go index 0ac2dfe..d703c64 100644 --- a/cmd/ximap/ximap.go +++ b/cmd/ximap/ximap.go @@ -1,21 +1,41 @@ package main import ( + "flag" "fmt" + "net/http" "os" + xprometheus "xinu.tv/imapstore/prometheus" + + "github.com/golang/glog" "github.com/jordwest/imap-server" "github.com/jordwest/imap-server/mailstore" + "github.com/prometheus/client_golang/prometheus" +) + +var ( + imapAddr = flag.String("imap", ":10143", "listen address for IMAP") + httpAddr = flag.String("http", ":10080", "listen address for HTTP") ) func main() { - store := mailstore.NewDummyMailstore() + flag.Parse() + defer glog.Flush() + + http.Handle("/metrics", prometheus.Handler()) + go func() { + glog.Fatal(http.ListenAndServe(*httpAddr, nil)) + }() + + var store mailstore.Mailstore + store = mailstore.NewDummyMailstore() + store = xprometheus.NewMailstore(store) s := imap.NewServer(store) s.Transcript = os.Stdout - s.Addr = ":10143" + s.Addr = *imapAddr - err := s.ListenAndServe() - if err != nil { + if err := s.ListenAndServe(); err != nil { fmt.Printf("Error creating test connection: %s\n", err) } }