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
|
<-sc
|
||||||
|
|
||||||
|
println("ledis-server is closing")
|
||||||
app.Close()
|
app.Close()
|
||||||
|
println("ledis-server is closed")
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,6 +13,7 @@ import (
|
||||||
"net"
|
"net"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
"syscall"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -165,6 +166,13 @@ func (c *respClient) handleRequest(reqData [][]byte) error {
|
||||||
c.resp.writeStatus(OK)
|
c.resp.writeStatus(OK)
|
||||||
c.resp.flush()
|
c.resp.flush()
|
||||||
c.conn.Close()
|
c.conn.Close()
|
||||||
|
return errClientQuit
|
||||||
|
} else if c.cmd == "shutdown" {
|
||||||
|
c.conn.Close()
|
||||||
|
|
||||||
|
// send kill signal
|
||||||
|
syscall.Kill(syscall.Getpid(), syscall.SIGTERM)
|
||||||
|
|
||||||
return errClientQuit
|
return errClientQuit
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue