Renamed
This commit is contained in:
parent
e89f97a467
commit
22d3aae633
@ -1,105 +1,105 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
"github.com/SommerEngineering/Ocean/CustomerDB"
|
"github.com/SommerEngineering/Ocean/CustomerDB"
|
||||||
"github.com/SommerEngineering/Ocean/ICCC"
|
"github.com/SommerEngineering/Ocean/ICCC"
|
||||||
"github.com/SommerEngineering/Ocean/Log"
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
"github.com/SommerEngineering/Ocean/NumGen"
|
"github.com/SommerEngineering/Ocean/NumGen"
|
||||||
"github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
"runtime"
|
"runtime"
|
||||||
"strconv"
|
"strconv"
|
||||||
)
|
)
|
||||||
|
|
||||||
// Init the system.
|
// Init the system.
|
||||||
func initSystem() {
|
func initSystem() {
|
||||||
|
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `The system is now starting.`)
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `The system is now starting.`)
|
||||||
|
|
||||||
// Set the desired amount of CPUs to use by Ocean. Default: 2
|
// Set the desired amount of CPUs to use by Ocean. Default: 2
|
||||||
utilizeCPUs := 2
|
utilizeCPUs := 2
|
||||||
if value, err := strconv.Atoi(ConfigurationDB.Read(`OceanUtilizeCPUs`)); err != nil {
|
if value, err := strconv.Atoi(ConfigurationDB.Read(`OceanUtilizeCPUs`)); err != nil {
|
||||||
// Case: Error! Use the default.
|
// Case: Error! Use the default.
|
||||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the OceanUtilizeCPUs configuration.`, `Use the default value instead.`)
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the OceanUtilizeCPUs configuration.`, `Use the default value instead.`)
|
||||||
} else {
|
} else {
|
||||||
utilizeCPUs = value
|
utilizeCPUs = value
|
||||||
}
|
}
|
||||||
|
|
||||||
// Set the amount of CPUs:
|
// Set the amount of CPUs:
|
||||||
runtime.GOMAXPROCS(utilizeCPUs)
|
runtime.GOMAXPROCS(utilizeCPUs)
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration OceanUtilizeCPUs is set.`, fmt.Sprintf(`value=%d`, utilizeCPUs))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration OceanUtilizeCPUs is set.`, fmt.Sprintf(`value=%d`, utilizeCPUs))
|
||||||
|
|
||||||
// Apply all desired logging devices:
|
// Apply all desired logging devices:
|
||||||
initLoggingDevices()
|
initLoggingDevices()
|
||||||
|
|
||||||
// Set the logging buffer size:
|
// Set the logging buffer size:
|
||||||
logBufferSize := 500
|
logBufferSize := 500
|
||||||
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogBufferSize`)); err != nil {
|
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogBufferSize`)); err != nil {
|
||||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogBufferSize configuration.`, `Use the default value instead.`)
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogBufferSize configuration.`, `Use the default value instead.`)
|
||||||
} else {
|
} else {
|
||||||
logBufferSize = value
|
logBufferSize = value
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.SetBufferSize(logBufferSize)
|
Log.SetBufferSize(logBufferSize)
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogBufferSize is set.`, fmt.Sprintf(`value=%d`, logBufferSize))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogBufferSize is set.`, fmt.Sprintf(`value=%d`, logBufferSize))
|
||||||
|
|
||||||
// Set the logging device delay (number of events):
|
// Set the logging device delay (number of events):
|
||||||
logDeviceDelayNumberEvents := 600
|
logDeviceDelayNumberEvents := 600
|
||||||
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogDeviceDelayNumberEvents`)); err != nil {
|
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogDeviceDelayNumberEvents`)); err != nil {
|
||||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogDeviceDelayNumberEvents configuration.`, `Use the default value instead.`)
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogDeviceDelayNumberEvents configuration.`, `Use the default value instead.`)
|
||||||
} else {
|
} else {
|
||||||
logDeviceDelayNumberEvents = value
|
logDeviceDelayNumberEvents = value
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.SetDeviceDelayNumberEvents(logDeviceDelayNumberEvents)
|
Log.SetDeviceDelayNumberEvents(logDeviceDelayNumberEvents)
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogDeviceDelayNumberEvents is set.`, fmt.Sprintf(`value=%d`, logDeviceDelayNumberEvents))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogDeviceDelayNumberEvents is set.`, fmt.Sprintf(`value=%d`, logDeviceDelayNumberEvents))
|
||||||
|
|
||||||
// Set the logging device delay time to flush (seconds):
|
// Set the logging device delay time to flush (seconds):
|
||||||
logDeviceDelayTime2FlushSeconds := 5
|
logDeviceDelayTime2FlushSeconds := 5
|
||||||
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogDeviceDelayTime2FlushSeconds`)); err != nil {
|
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogDeviceDelayTime2FlushSeconds`)); err != nil {
|
||||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogDeviceDelayTime2FlushSeconds configuration.`, `Use the default value instead.`)
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogDeviceDelayTime2FlushSeconds configuration.`, `Use the default value instead.`)
|
||||||
} else {
|
} else {
|
||||||
logDeviceDelayTime2FlushSeconds = value
|
logDeviceDelayTime2FlushSeconds = value
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.SetDeviceDelayTimeoutSeconds(logDeviceDelayTime2FlushSeconds)
|
Log.SetDeviceDelayTimeoutSeconds(logDeviceDelayTime2FlushSeconds)
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogDeviceDelayTime2FlushSeconds is set.`, fmt.Sprintf(`value=%d`, logDeviceDelayTime2FlushSeconds))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogDeviceDelayTime2FlushSeconds is set.`, fmt.Sprintf(`value=%d`, logDeviceDelayTime2FlushSeconds))
|
||||||
|
|
||||||
// Set the logging timeout (seconds):
|
// Set the logging timeout (seconds):
|
||||||
logTimeoutSeconds := 3
|
logTimeoutSeconds := 3
|
||||||
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogTimeoutSeconds`)); err != nil {
|
if value, err := strconv.Atoi(ConfigurationDB.Read(`LogTimeoutSeconds`)); err != nil {
|
||||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogTimeoutSeconds configuration.`, `Use the default value instead.`)
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactUnknown, LM.MessageNameCONFIGURATION, `Was not able to read the LogTimeoutSeconds configuration.`, `Use the default value instead.`)
|
||||||
} else {
|
} else {
|
||||||
logTimeoutSeconds = value
|
logTimeoutSeconds = value
|
||||||
}
|
}
|
||||||
|
|
||||||
Log.SetTimeoutSeconds(logTimeoutSeconds)
|
Log.SetTimeoutSeconds(logTimeoutSeconds)
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogTimeoutSeconds is set.`, fmt.Sprintf(`value=%d`, logTimeoutSeconds))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameCONFIGURATION, `Configuration LogTimeoutSeconds is set.`, fmt.Sprintf(`value=%d`, logTimeoutSeconds))
|
||||||
|
|
||||||
// Apply these changes:
|
// Apply these changes:
|
||||||
Log.ApplyConfigurationChanges()
|
Log.ApplyConfigurationChanges()
|
||||||
Log.LoggingIsReady()
|
Log.LoggingIsReady()
|
||||||
|
|
||||||
// Register all system shutdown handlers:
|
// Register all system shutdown handlers:
|
||||||
//
|
//
|
||||||
// Please notice: If the shutdown event occurs ...
|
// Please notice: If the shutdown event occurs ...
|
||||||
// * all application handlers are called (order: last comed, first served)
|
// * all application handlers are called (order: last comed, first served)
|
||||||
// * then, these system handlers are called (order: last comed, first served)
|
// * then, these system handlers are called (order: last comed, first served)
|
||||||
// * and finally, the logging device / system gets closed
|
// * and finally, the logging device / system gets closed
|
||||||
Shutdown.InitShutdown()
|
Shutdown.InitShutdown()
|
||||||
Shutdown.AddShutdownHandler(ConfigurationDB.ShutdownFunction{})
|
Shutdown.AddShutdownHandler(ConfigurationDB.ShutdownFunction{})
|
||||||
Shutdown.AddShutdownHandler(CustomerDB.ShutdownFunction{})
|
Shutdown.AddShutdownHandler(CustomerDB.ShutdownFunction{})
|
||||||
Shutdown.AddShutdownHandler(ICCC.ShutdownFunction{})
|
Shutdown.AddShutdownHandler(ICCC.ShutdownFunction{})
|
||||||
Shutdown.AddShutdownHandler(NumGen.ShutdownFunction{})
|
Shutdown.AddShutdownHandler(NumGen.ShutdownFunction{})
|
||||||
|
|
||||||
// The logging subsystem is not registered here, because it will be automated called at the end
|
// The logging subsystem is not registered here, because it will be automated called at the end
|
||||||
|
|
||||||
// Register all system ICCC commands:
|
// Register all system ICCC commands:
|
||||||
ICCC.Registrar(ICCC.ChannelSYSTEM, `System::Start`, icccSystemStart)
|
ICCC.Registrar(ICCC.ChannelSYSTEM, `System::Start`, icccSystemStart)
|
||||||
|
|
||||||
// Start the ICCC Listener Cache:
|
// Start the ICCC Listener Cache:
|
||||||
ICCC.InitCacheNow() // Blocking, until the job is done
|
ICCC.InitCacheNow() // Blocking, until the job is done
|
||||||
ICCC.StartCacheTimer()
|
ICCC.StartCacheTimer()
|
||||||
}
|
}
|
@ -1,18 +1,18 @@
|
|||||||
package System
|
package System
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/SommerEngineering/Ocean/WebServer"
|
"github.com/SommerEngineering/Ocean/WebServer"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
// The main function for the application.
|
// The main function for the application.
|
||||||
func StartAndBlockForever() {
|
func StartAndBlockForever() {
|
||||||
|
|
||||||
// Starts the public and private web server with own threads:
|
// Starts the public and private web server with own threads:
|
||||||
WebServer.Start()
|
WebServer.Start()
|
||||||
|
|
||||||
// Wait forever:
|
// Wait forever:
|
||||||
for {
|
for {
|
||||||
time.Sleep(1 * time.Second)
|
time.Sleep(1 * time.Second)
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user