Exemplo n.º 1
0
func main() {
	configFilePath := flag.String("configPath", "", "path to the configuration file")

	flag.Parse()

	conf := config.Configuration(*configFilePath)

	if len(conf.Syslog) > 0 {
		logging.SetSysLogger(conf.Syslog)
	}
	logging.SetLevel(conf.LogLevel)

	dropsonde.Initialize("localhost:"+strconv.Itoa(conf.MetronPort), valuemetricsender.ForwarderOrigin)

	go func() {
		err := tcp.Open(conf.IncomingPort, forwarder.StartMessageForwarder(valuemetricsender.NewValueMetricSender()))
		if err != nil {
			logging.Log.Panic("Could not open the TCP port", err)
		}
	}()

	logging.Log.Info("Bosh HM forwarder initialized")

	infoHandler := handlers.NewInfoHandler()
	router := mux.NewRouter()
	router.Handle("/info", infoHandler).Methods("GET")

	if conf.DebugPort > 0 {
		go pprofServer(conf.DebugPort)
	}

	logging.Log.Info(fmt.Sprintf("Starting Info Server on port %d", conf.InfoPort))

	err := http.ListenAndServe(net.JoinHostPort("", fmt.Sprintf("%d", conf.InfoPort)), router)
	if err != nil {
		logging.Log.Panic("Failed to start up alerter: ", err)
	}
}
Exemplo n.º 2
0
	"encoding/json"

	. "github.com/onsi/gomega"
)

var _ = Describe("InfoHandler", func() {

	var (
		req      *http.Request
		recorder *httptest.ResponseRecorder
		handler  http.Handler
	)

	BeforeEach(func() {
		recorder = httptest.NewRecorder()
		handler = handlers.NewInfoHandler()
		req = createRequest("GET", "/info")
	})

	Context("with a good version file", func() {
		BeforeEach(func() {

		})

		It("returns the current time (in ms) and version", func() {
			handler.ServeHTTP(recorder, req)

			Expect(recorder.Code).To(Equal(http.StatusOK))

			var bodyContents map[string]string