Skip to content
/ zerodt Public

Zero downtime restart and graceful shutdown in one line of code

License

Notifications You must be signed in to change notification settings

ssgreg/zerodt

Folders and files

NameName
Last commit message
Last commit date

Latest commit

ce4695f · Apr 18, 2018

History

45 Commits
Aug 30, 2017
Aug 16, 2017
Aug 16, 2017
Aug 17, 2017
Aug 4, 2017
Aug 27, 2017
Apr 18, 2018
Aug 22, 2017
Apr 18, 2018
Aug 18, 2017
Aug 30, 2017
Aug 17, 2017
Aug 17, 2017
Aug 17, 2017
Aug 6, 2017
Aug 17, 2017
Aug 17, 2017
Aug 30, 2017
Aug 29, 2017
Aug 17, 2017
Aug 17, 2017

Repository files navigation

ZeroDT

GoDoc Build Status Go Report Status

Package ZeroDT offers a zero downtime restart and a graceful shutdown for HTTP servers. Key features:

  • supported both stateless and stateful servers
  • compatible with systemd's socket activation
  • based on out-of-the-box http.Server
  • work with any number of servers
  • not a framework

Example

The simplest way to use ZeroDT is to pass your http.Server to the zerodt.NewApp function and call zerodt.ListenAndServe for an object it returns:

package main

import (
    "io"
    "net/http"
    "time"

    "github.com/ssgreg/zerodt"
)

func hello(w http.ResponseWriter, r *http.Request) {
    io.WriteString(w, "Hello world!")
}

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

    a := zerodt.NewApp(&http.Server{Addr: ":8081", Handler: mux})
    a.ListenAndServe()
}

Adopting your HTTP server to use as systemd's service

Under construction