grace

Graceful restart & zero downtime deploy for Go servers.

  • 所有者: facebookarchive/grace
  • 平台:
  • 许可证: MIT License
  • 分类:
  • 主题:
  • 喜欢:
    0
      比较:

Github星跟踪图

grace Build Status

Package grace provides a library that makes it easy to build socket
based servers that can be gracefully terminated & restarted (that is,
without dropping any connections).

It provides a convenient API for HTTP servers including support for TLS,
especially if you need to listen on multiple ports (for example a secondary
internal only admin server). Additionally it is implemented using the same API
as systemd providing socket
activation

compatibility to also provide lazy activation of the server.

Usage

Demo HTTP Server with graceful termination and restart:
https://github.com/facebookgo/grace/blob/master/gracedemo/demo.go

  1. Install the demo application

     go get github.com/facebookgo/grace/gracedemo
    
  2. Start it in the first terminal

     gracedemo
    

    This will output something like:

     2013/03/25 19:07:33 Serving [::]:48567, [::]:48568, [::]:48569 with pid 14642.
    
  3. In a second terminal start a slow HTTP request

     curl 'http://localhost:48567/sleep/?duration=20s'
    
  4. In a third terminal trigger a graceful server restart (using the pid from your output):

     kill -USR2 14642
    
  5. Trigger another shorter request that finishes before the earlier request:

     curl 'http://localhost:48567/sleep/?duration=0s'
    

If done quickly enough, this shows the second quick request will be served by
the new process (as indicated by the PID) while the slow first request will be
served by the first server. It shows how the active connection was gracefully
served before the server was shutdown. It is also showing that at one point
both the new as well as the old server was running at the same time.

Documentation

http.Server graceful termination and restart:
https://godoc.org/github.com/facebookgo/grace/gracehttp

net.Listener graceful termination and restart:
https://godoc.org/github.com/facebookgo/grace/gracenet

主要指标

概览
名称与所有者facebookarchive/grace
主编程语言Go
编程语言Go (语言数: 1)
平台
许可证MIT License
所有者活动
创建于2012-06-04 22:23:04
推送于2019-02-13 01:07:15
最后一次提交2018-07-05 21:00:59
发布数0
用户参与
星数4.9k
关注者数160
派生数425
提交数93
已启用问题?
问题数30
打开的问题数4
拉请求数6
打开的拉请求数5
关闭的拉请求数5
项目设置
已启用Wiki?
已存档?
是复刻?
已锁定?
是镜像?
是私有?