Misc.
+ Removed the fixed shutdown time + Added the configuration for the public web server + Refactored the old web server settings + Improved the handling of shutdown handlers. It is not save! + Bugfix: The server start was no longer blocking
This commit is contained in:
1 parent
96bcb5da8f
commit
3348e552cc
10 files changed
+63
-20
No files matched your search
+16
-4
@@ -1,6 +1,8 @@
|
||||
package Shutdown
|
||||
|
||||
import (
|
||||
"container/list"
|
||||
"fmt"
|
||||
"github.com/SommerEngineering/Ocean/Log"
|
||||
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||
"os"
|
||||
@@ -20,12 +22,22 @@ func executeShutdown() {
|
||||
|
||||
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()
|
||||
safeCall(handler)
|
||||
}
|
||||
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelWARN, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameSHUTDOWN, `The system is shutting down now.`)
|
||||
Log.Flush()
|
||||
|
||||
os.Exit(6)
|
||||
os.Exit(0)
|
||||
}
|
||||
|
||||
func safeCall(handler *list.Element) {
|
||||
defer func() {
|
||||
if err := recover(); err != nil {
|
||||
errObj := fmt.Errorf("%v", err)
|
||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.SeverityNone, LM.ImpactNone, LM.MessageNameSHUTDOWN, `An error occurs for a shutdown handler.`, errObj.Error())
|
||||
}
|
||||
}()
|
||||
|
||||
h := handler.Value.(ShutdownHandler)
|
||||
h.Shutdown()
|
||||
}
|
||||
Reference in new issue
Block a user