grace

package
v1.5.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 16, 2015 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Description: http://grisha.org/blog/2014/06/03/graceful-restart-in-golang/

Usage:

import(

  "log"
	 "net/http"
	 "os"

  "github.com/astaxie/beego/grace"

)

 func handler(w http.ResponseWriter, r *http.Request) {
	  w.Write([]byte("WORLD!"))
 }

 func main() {
     mux := http.NewServeMux()
     mux.HandleFunc("/hello", handler)

	    err := grace.ListenAndServe("localhost:8080", mux1)
     if err != nil {
		   log.Println(err)
	    }
     log.Println("Server on 8080 stopped")
	     os.Exit(0)
   }

Index

Constants

View Source
const (
	PRE_SIGNAL = iota
	POST_SIGNAL

	STATE_INIT
	STATE_RUNNING
	STATE_SHUTTING_DOWN
	STATE_TERMINATE
)

Variables

View Source
var (
	DefaultReadTimeOut    time.Duration
	DefaultWriteTimeOut   time.Duration
	DefaultMaxHeaderBytes int
	DefaultTimeout        time.Duration
)

Functions

func ListenAndServe

func ListenAndServe(addr string, handler http.Handler) error

refer http.ListenAndServe

func ListenAndServeTLS

func ListenAndServeTLS(addr string, certFile string, keyFile string, handler http.Handler) error

refer http.ListenAndServeTLS

func NewServer

func NewServer(addr string, handler http.Handler) (srv *graceServer)

NewServer returns a new graceServer.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL