revel/revel — pull request #593 by ludmiloff (2014-04-30 06:42:58+00:00)
Title: Graceful server shutdown

Also, OnAppShutdown hook added allowing to perform some pre-shutdown code before the server get closed. The usage is similar to OnAppStart:

// Example:
//
// // from: yourapp/app/controllers/somefile.go
// func InitDB() {
// // do DB connection stuff here
// }
//
// func CloseConn() {
// // close db connection here
// }
//
// func FillCache() {
// // fill a cache from DB
// // this depends on InitDB having been run
// }
//
// // from: yourapp/app/init.go
// func init() {
// // set up filters...
//
// // register startup functions
// revel.OnAppStart(InitDB)
// revel.OnAppStart(FillCache)
// revel.OnAppShutdown(CloseCon)
// }