diff --git a/cmd/ledis-server/main.go b/cmd/ledis-server/main.go index 7987733..d8d3d9c 100644 --- a/cmd/ledis-server/main.go +++ b/cmd/ledis-server/main.go @@ -113,5 +113,7 @@ func main() { <-sc + println("ledis-server is closing") app.Close() + println("ledis-server is closed") } diff --git a/server/client_resp.go b/server/client_resp.go index 47d7d58..65b8b97 100644 --- a/server/client_resp.go +++ b/server/client_resp.go @@ -13,6 +13,7 @@ import ( "net" "runtime" "strconv" + "syscall" "time" ) @@ -165,6 +166,13 @@ func (c *respClient) handleRequest(reqData [][]byte) error { c.resp.writeStatus(OK) c.resp.flush() c.conn.Close() + return errClientQuit + } else if c.cmd == "shutdown" { + c.conn.Close() + + // send kill signal + syscall.Kill(syscall.Getpid(), syscall.SIGTERM) + return errClientQuit }