graceful

package module
v0.0.0-...-dd4ba55 Latest Latest
Warning

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

Go to latest
Published: May 27, 2019 License: MIT Imports: 12 Imported by: 0

README

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

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ListenAndServe

func ListenAndServe(server *http.Server, pidFile string)

func ListenAndServeTLS

func ListenAndServeTLS(server *http.Server, certFile, keyFile, pidFile string)

Types

This section is empty.

Jump to

Keyboard shortcuts

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