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
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"flag"
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
|
xprometheus "xinu.tv/imapstore/prometheus"
|
||||||
|
|
||||||
|
"github.com/golang/glog"
|
||||||
"github.com/jordwest/imap-server"
|
"github.com/jordwest/imap-server"
|
||||||
"github.com/jordwest/imap-server/mailstore"
|
"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() {
|
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 := imap.NewServer(store)
|
||||||
s.Transcript = os.Stdout
|
s.Transcript = os.Stdout
|
||||||
s.Addr = ":10143"
|
s.Addr = *imapAddr
|
||||||
|
|
||||||
err := s.ListenAndServe()
|
if err := s.ListenAndServe(); err != nil {
|
||||||
if err != nil {
|
|
||||||
fmt.Printf("Error creating test connection: %s\n", err)
|
fmt.Printf("Error creating test connection: %s\n", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user