Add a generic registerShutdown function for graceful exit (#2344)

* Add a generic registerShutdown function for graceful exit
* Add shutdown callback test case
This commit is contained in:
Anis Elleuch
2016-08-05 22:48:31 +02:00
committed by Harshavardhana
parent 62c0612eac
commit d28fb5fe23
7 changed files with 127 additions and 21 deletions
+6
View File
@@ -275,6 +275,11 @@ func serverMain(c *cli.Context) {
// Prints the formatted startup message.
printStartupMessage(endPoints)
registerShutdown(func() errCode {
// apiServer.Stop()
return exitSuccess
})
// Start server.
// Configure TLS if certs are available.
if tls {
@@ -283,5 +288,6 @@ func serverMain(c *cli.Context) {
// Fallback to http.
err = apiServer.ListenAndServe()
}
fatalIf(err, "Failed to start minio server.")
}