proc

package
v2.0.0-alpha4+incompat... Latest Latest
Warning

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

Go to latest
Published: Oct 7, 2015 License: BSD-3-Clause Imports: 12 Imported by: 0

Documentation

Overview

Package proc allows you to configure servers to be restarted with negligible downtime.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Listen

func Listen(port string) (l net.Listener, err error)

Listen tries to create a listener on the specified tcp port. Before creating the listener, it checks to see if there is another server already using the port. If there is one, it sends a USR1 signal requesting the server to shutdown, and then attempts to to create the listener.

func ListenAndServe

func ListenAndServe(port string) os.Signal

ListenAndServe combines Listen and Wait to also run an http server on the specified port. If it fails to obtain a listener, the program is fatally terminated. The return value is the signal received for termination

func Published

func Published(l net.Listener, countTag, acceptTag string) net.Listener

Published creates a wrapper for net.Listener that publishes connection stats.

func Wait

func Wait() os.Signal

Wait creates an HTTP handler on pidURL, and serves the current process pid on it. It then creates a signal handler and waits for SIGTERM or SIGUSR1, and returns when the signal is received. A new server that comes up will query this URL. If it receives a valid response, it will send a SIGUSR1 signal and attempt to bind to the port the current server is using.

Types

type CountingListener

type CountingListener struct {
	net.Listener
	ConnCount, ConnAccept *stats.Int
}

func (*CountingListener) Accept

func (l *CountingListener) Accept() (c net.Conn, err error)

Accept increments stats counters before returning a connection.

Jump to

Keyboard shortcuts

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