Ocean/Shutdown/Shutdown.go
Thorsten Sommer f33f7b5c29 Refactoring, Bugfix & Updates
+ Refactored all imports
+ Fixed a bug for the logging regarding removing \n \t \r
+ Updated to current MGO release
+ Changed the name of ICCC
2014-10-19 19:19:11 +02:00

32 lines
916 B
Go

package Shutdown
import (
"github.com/SommerEngineering/Ocean/Log"
LM "github.com/SommerEngineering/Ocean/Log/Meta"
"os"
)
type ShutdownHandler interface {
Shutdown()
}
func AddShutdownHandler(handler ShutdownHandler) {
shutdownHandlers.PushFront(handler)
}
func executeShutdown() {
sig := <-shutdownSignal
stopAllRequests = true
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelWARN, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameSHUTDOWN, `The system was called to shutting down.`, sig.String(), `Call now all shutdown handlers.`)
for handler := shutdownHandlers.Front(); handler != nil; handler = handler.Next() {
h := handler.Value.(ShutdownHandler)
h.Shutdown()
}
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelWARN, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameSHUTDOWN, `The system is shutting down now.`)
Log.Flush()
os.Exit(6)
}