Skip to content

Commit

Permalink
Add crash endpoint
Browse files Browse the repository at this point in the history
  • Loading branch information
jskswamy committed Feb 7, 2019
1 parent e86fb53 commit dadcd0a
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions pkg/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package handler
import (
"github.com/gin-gonic/gin"
"github.com/thecasualcoder/dobby/pkg/config"
"log"
"os"
"strconv"
)
Expand All @@ -24,6 +25,11 @@ func Version(c *gin.Context) {
c.JSON(200, gin.H{"version": version})
}

// Crash will make dobby to kill itself
func Crash(_ *gin.Context) {
log.Fatal("you asked me do so, killing myself :-)")
}

func init() {
healthy, err := strconv.ParseBool(os.Getenv("HEALTH"))

Expand Down
1 change: 1 addition & 0 deletions pkg/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,6 @@ func Run(bindAddress, port string) error {

r.GET("/health", handler.Health)
r.GET("/version", handler.Version)
r.PUT("/state/crash", handler.Crash)
return r.Run(fmt.Sprintf("%s:%s", bindAddress, port))
}

0 comments on commit dadcd0a

Please sign in to comment.