graceful

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

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

Go to latest
Published: Jan 17, 2023 License: MIT Imports: 6 Imported by: 0

README

tcp-graceful

一个基于golang的优雅热重启库实现,支持golang-TCP服务

关联文章:Golang 系统编程:如何实现对后台服务优雅的热重启?

测试方法:

  1. 启动主程序,通过cat /var/run/tmp.pid获取当前主进程的$pid
  2. 通过kill -SIGHUP $pid执行主程序的热重启机制
  3. 重启后的生成新的主程序不改变当前运行的相对路径

Documentation

Index

Constants

View Source
const (
	DEFAULT_SOCKET_FILE = "/tmp/tcp-graceful.sock"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type HandleTcpConns

type HandleTcpConns func(net.Conn)

type TcpConnManager

type TcpConnManager struct {
	sync.WaitGroup
	// contains filtered or unexported fields
}

func NewTcpConnManager

func NewTcpConnManager() *TcpConnManager

func (*TcpConnManager) Add

func (m *TcpConnManager) Add(num int64)

func (*TcpConnManager) Done

func (m *TcpConnManager) Done()

func (*TcpConnManager) NoAliveConn

func (m *TcpConnManager) NoAliveConn() bool

type TcpServer

type TcpServer struct {
	// contains filtered or unexported fields
}

func NewTcpServer

func NewTcpServer(addr string, port int) (*TcpServer, error)

NewTcpServer ...

func NewTcpServerFromENV

func NewTcpServerFromENV(old_fd uintptr) (*TcpServer, error)

NewTcpServerFromENV ...

func (*TcpServer) GetListenerFD

func (s *TcpServer) GetListenerFD() (uintptr, error)

getListenerFD ...

func (*TcpServer) HandleAccept

func (s *TcpServer) HandleAccept(handleTcpConn HandleTcpConns)

handleAccept ...

func (*TcpServer) StopAccept

func (s *TcpServer) StopAccept()

stopAccept ...

func (*TcpServer) WaitAllConnectionsQuit

func (s *TcpServer) WaitAllConnectionsQuit()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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