/socket

Golang gracefully deploy/restart server

Primary LanguageGo

Gracefully deploy/restart server

Usage

  1. Go get && import this repo
    go get github.com/bitxel/socket
  1. Update code, change net.Listen to socket.Listen
    l, err := socket.Listen("tcp", ":12345")
  1. Handle singal USR2 && run new binary
    sigch := make(chan os.Signal, 1)
    signal.Notify(sigch, syscall.SIGUSR2)
    <-sigch
    socket.Fork()
  1. Test
    kill -USR2 pid

Demo

Link