Skip to content

Graceful restart & zero downtime deploy for Go servers.

License

Notifications You must be signed in to change notification settings

douglarek/zerodown

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zerodown Build Status

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

Usage

Demo HTTP Server with graceful termination and restart: https://github.com/douglarek/zerodown/blob/master/zerodowndemo/server.go

  1. Install the demo application

     go get github.com/douglarek/zerodown/zerodowndemo
    
  2. Start it in the first terminal

     zerodowndemo
    
  3. In a second terminal start a slow HTTP request

     curl 'http://localhost:8080/?duration=20s'
    
  4. In a third terminal trigger a graceful server restart:

     kill -USR2 [zerodowndemo pid]
    
  5. Trigger another shorter request that finishes before the earlier request:

     curl 'http://localhost:8080/?duration=0s'
    

If done quickly enough, this shows the second quick request will be served by the new process 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.

About

Graceful restart & zero downtime deploy for Go servers.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages