Initial commit of Ocean's local development

This commit is contained in:
Thorsten Sommer committed 2014-04-26 11:18:56 +02:00
1 parent 9944a9e1df
commit 86451938ec
116 files changed
+3320

No files matched your search

+6
View File
@@ -0,0 +1,6 @@
package Shutdown
func IsDown() (result bool) {
result = stopAllRequests
return
}
+13
View File
@@ -0,0 +1,13 @@
package Shutdown
import "container/list"
import "os/signal"
import "os"
func InitShutdown() {
shutdownHandlers = list.New()
// Apply the shutdown handler:
signal.Notify(shutdownSignal, os.Interrupt, os.Kill)
go executeShutdown()
}
+29
View File
@@ -0,0 +1,29 @@
package Shutdown
import "os"
import "github.com/SommerEngineering/Ocean/Log"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
type ShutdownHandler interface {
Shutdown()
}
func AddShutdownHandler(handler ShutdownHandler) {
shutdownHandlers.PushBack(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)
}
+12
View File
@@ -0,0 +1,12 @@
package Shutdown
import "os"
import "container/list"
import LM "github.com/SommerEngineering/Ocean/Log/Meta"
var (
shutdownSignal chan os.Signal = make(chan os.Signal)
shutdownHandlers *list.List = nil
senderName LM.Sender = `System::Shutdown`
stopAllRequests bool = false
)