Skip to content

vapao/go-graceful

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 

Repository files navigation

go-graceful

golang http graceful restart

Usage

package main

import (
	"net/http"
	"io"
	"github.com/Yooke/go-graceful"
)

func main() {
	http.HandleFunc("/", ping)

	graceful.ListenAndServe(&http.Server{Addr: ":8000"}, "/var/run/app.pid")
}

func ping(w http.ResponseWriter, r *http.Request) {
	io.WriteString(w, "pong")
}

With systemctl

[Unit]
Description=Application Desc
After=network.target

[Service]
Type=simple
PIDFile=/var/run/app.pid
ExecStart=/path/to/app
ExecReload=/bin/kill -USR2 $MAINPID

[Install]
WantedBy=multi-user.target

About

golang http graceful restart

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages