mirror of https://github.com/ledisdb/ledisdb.git
support shutdown command
This commit is contained in:
parent
a999f2201d
commit
9bfd3b2208
|
@ -113,5 +113,7 @@ func main() {
|
|||
|
||||
<-sc
|
||||
|
||||
println("ledis-server is closing")
|
||||
app.Close()
|
||||
println("ledis-server is closed")
|
||||
}
|
||||
|
|
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue