2014-04-26 09:18:56 +00:00
|
|
|
package Shutdown
|
|
|
|
|
2014-10-19 17:19:11 +00:00
|
|
|
import (
|
|
|
|
"container/list"
|
|
|
|
"os"
|
|
|
|
"os/signal"
|
|
|
|
)
|
2014-04-26 09:18:56 +00:00
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// Init the package.
|
2014-09-13 10:56:35 +00:00
|
|
|
func init() {
|
2014-04-26 09:18:56 +00:00
|
|
|
shutdownHandlers = list.New()
|
2014-09-13 10:56:35 +00:00
|
|
|
}
|
|
|
|
|
2015-06-17 15:44:52 +00:00
|
|
|
// The manual init for the shutdown notify handler.
|
2014-09-13 10:56:35 +00:00
|
|
|
func InitShutdown() {
|
2014-04-26 09:18:56 +00:00
|
|
|
|
|
|
|
// Apply the shutdown handler:
|
|
|
|
signal.Notify(shutdownSignal, os.Interrupt, os.Kill)
|
2015-06-17 15:44:52 +00:00
|
|
|
|
|
|
|
// Start a new thread which waits for the shutdown event:
|
2014-04-26 09:18:56 +00:00
|
|
|
go executeShutdown()
|
|
|
|
}
|