Add prometheus metric exporting.
Wrap existing mailstore with prometheus monitoring one. Add flags for IMAP & HTTP listen addresses.
This commit is contained in:
parent
c585591c71
commit
2b1aedb7a0
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user