1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-14 10:23:00 +02:00
echo/website/content/recipes/graceful-shutdown.md
Vishal Rana 5587974933 Added GAE recipe
Signed-off-by: Vishal Rana <vr@labstack.com>
2015-10-07 17:17:11 -07:00

1.1 KiB

title menu
Graceful Shutdown
main
parent
recipes

With graceful

server.go

package main

import (
	"net/http"
	"time"

	"github.com/labstack/echo"
	"github.com/tylerb/graceful"
)

func main() {
	// Setup
	e := echo.New()
	e.Get("/", func(c *echo.Context) error {
		return c.String(http.StatusOK, "Sue sews rose on slow jor crows nose")
	})

	graceful.ListenAndServe(e.Server(":1323"), 5*time.Second)
}

With grace

server.go

package main

import (
	"net/http"

	"github.com/facebookgo/grace/gracehttp"
	"github.com/labstack/echo"
)

func main() {
	// Setup
	e := echo.New()
	e.Get("/", func(c *echo.Context) error {
		return c.String(http.StatusOK, "Six sick bricks tick")
	})

	gracehttp.Serve(e.Server(":1323"))
}

Maintainers

Source Code

graceful

grace