--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/.hgignore Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,3 @@
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/Dockerfile Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,14 @@
+FROM golang:stretch as build +RUN CGO_ENABLED=0 GOOS=linux go build -o carrier -a -ldflags '-extldflags "-static" -s' . +COPY --from=build /app/carrier /carrier --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/config/config.go Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,34 @@
+ "github.com/kelseyhightower/envconfig" + ListenAddr string `envconfig:"LISTEN_ADDR" default:":3333"` + UptimeRobotToken string `envconfig:"UPTIME_ROBOT_TOKEN" required:"true"` + TwilioAccountSID string `envconfig:"TWILIO_ACCOUNT_SID" required:"true"` + TwilioAuthToken string `envconfig:"TWILIO_AUTH_TOKEN" required:"true"` + err := envconfig.Process("CARRIER", &config) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/convey.yml Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,41 @@
+ tag: ${REGISTRY}/${REPO}:${TAG} + username: ${REGISTRY_USERNAME} + password: ${REGISTRY_PASSWORD} + images: ${REGISTRY}/${REPO}:${TAG} + - tasks: [import, build] + - tasks: [import, build, login, push] --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/go.mod Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,6 @@
+module bitbucket.org/pidgin/carrier + github.com/kelseyhightower/envconfig v1.3.0 + github.com/sirupsen/logrus v1.4.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/go.sum Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,11 @@
+github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38= +github.com/kelseyhightower/envconfig v1.3.0 h1:IvRS4f2VcIQy6j4ORGIf9145T/AsUB+oY8LyvN8BXNM= +github.com/kelseyhightower/envconfig v1.3.0/go.mod h1:cccZRl6mQpaq41TPp5QxidR+Sa3axMbJDNb//FQX6Gg= +github.com/konsorten/go-windows-terminal-sequences v1.0.1/go.mod h1:T0+1ngSBFLxvqU3pZ+m/2kptfBszLMUkC4ZK/EgS/cQ= +github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4= +github.com/sirupsen/logrus v1.4.1 h1:GL2rEmy6nsikmW0r8opw9JIRScdMF5hA8cOYLH7In1k= +github.com/sirupsen/logrus v1.4.1/go.mod h1:ni0Sbl8bgC9z8RoU9G6nDWqqs/fq4eDPysMBDgk/93Q= +github.com/stretchr/objx v0.1.1/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME= +github.com/stretchr/testify v1.2.2/go.mod h1:a8OnRcib4nhh0OaRAV+Yts87kKdq0PP7pXfy6kDkUVs= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33 h1:I6FyU15t786LL7oL/hn43zqTuEGr4PN7F4XJ1p4E3Y8= +golang.org/x/sys v0.0.0-20180905080454-ebe1bf3edb33/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY= --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.go Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,59 @@
+ log "github.com/sirupsen/logrus" + "bitbucket.org/pidgin/carrier/config" + "bitbucket.org/pidgin/carrier/server" + log.SetOutput(os.Stdout) + log.SetLevel(log.DebugLevel) + formatter := &log.TextFormatter{ + switch os.Getenv("TERM") { + formatter.DisableColors = true + log.SetFormatter(formatter) + // create a signal channel for catching os signals + signalChan := make(chan os.Signal, 1) + signal.Notify(signalChan, syscall.SIGINT, syscall.SIGTERM) + // create an error channel to catch fatal errors + errChan := make(chan error, 1) + // create the http sever and run it in a go routine + server := server.NewServer(config.Get().ListenAddr, errChan) + log.Fatalf("error: %s", err) + case s := <-signalChan: + log.Warnf("captured %v, exiting...", s) --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/server.go Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,53 @@
+ log "github.com/sirupsen/logrus" +func healthzHandler(w http.ResponseWriter, r *http.Request) { + status := http.StatusMethodNotAllowed + if r.Method == http.MethodGet { +func httpLogger(handler http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + log.Infof("%s %s %s\n", r.RemoteAddr, r.Method, r.URL) + handler.ServeHTTP(w, r) +func NewServer(addr string, errChan chan error) *Server { + mux := http.NewServeMux() + mux.HandleFunc("/healthz", healthzHandler) + mux.HandleFunc("/uptime-robot", uptimeRobotHandler) + Handler: httpLogger(mux), +func (s *Server) Start() { + log.Infof("http server started") + s.errChan <- s.server.ListenAndServe() +func (s *Server) Stop() { --- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/server/uptimerobot.go Sun May 12 05:00:08 2019 -0500
@@ -0,0 +1,14 @@
+// monitorID=*monitorID*&monitorURL=*monitorURL*&monitorFriendlyName=*monitorFriendlyName*&alertType=*alertType*&alertTypeFriendlyName=*alertTypeFriendlyName*&alertDetails=*alertDetails*&alertDuration=*alertDuration*&monitorAlertContacts=*monitorAlertContacts* +func uptimeRobotHandler(w http.ResponseWriter, r *http.Request) { + if r.Method != http.MethodPost { + w.WriteHeader(http.StatusMethodNotAllowed)