diff --git a/pkg/handler/handler.go b/pkg/handler/handler.go index 08120e0..223d7b4 100644 --- a/pkg/handler/handler.go +++ b/pkg/handler/handler.go @@ -3,6 +3,7 @@ package handler import ( "github.com/gin-gonic/gin" "github.com/thecasualcoder/dobby/pkg/config" + "log" "os" "strconv" ) @@ -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")) diff --git a/pkg/server.go b/pkg/server.go index 69aa6b7..91d9a0c 100644 --- a/pkg/server.go +++ b/pkg/server.go @@ -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)) }