Add possibility to provide version (#46)
This commit is contained in:
parent
44b236e2ef
commit
20b93f42d4
@ -267,6 +267,15 @@ p {
|
|||||||
.filterformcontainer {
|
.filterformcontainer {
|
||||||
text-align: center;
|
text-align: center;
|
||||||
}
|
}
|
||||||
|
.introtext {
|
||||||
|
margin-bottom: 30px;
|
||||||
|
color: black;
|
||||||
|
font-size: 20px;
|
||||||
|
}
|
||||||
|
.admintextblock {
|
||||||
|
margin-top: 16px;
|
||||||
|
color: black;
|
||||||
|
}
|
||||||
@media (max-width: 991px) {
|
@media (max-width: 991px) {
|
||||||
.icons.oneback {
|
.icons.oneback {
|
||||||
margin-left: 113px;
|
margin-left: 113px;
|
||||||
|
@ -5,6 +5,7 @@ import (
|
|||||||
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
"github.com/SommerEngineering/Ocean/MimeTypes"
|
"github.com/SommerEngineering/Ocean/MimeTypes"
|
||||||
"github.com/SommerEngineering/Ocean/Shutdown"
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"github.com/SommerEngineering/Ocean/System/Version"
|
||||||
"net/http"
|
"net/http"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -17,9 +18,13 @@ func HandlerOverview(response http.ResponseWriter, request *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Get the data ready:
|
||||||
|
data := AdminWebOverview{}
|
||||||
|
data.Version = Version.GetVersion()
|
||||||
|
|
||||||
// Write the MIME type and execute the template:
|
// Write the MIME type and execute the template:
|
||||||
MimeTypes.Write2HTTP(response, MimeTypes.TypeWebHTML)
|
MimeTypes.Write2HTTP(response, MimeTypes.TypeWebHTML)
|
||||||
if executeError := AdminTemplates.ExecuteTemplate(response, `Overview`, nil); executeError != nil {
|
if executeError := AdminTemplates.ExecuteTemplate(response, `Overview`, data); executeError != nil {
|
||||||
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameEXECUTE, `Was not able to execute the admin's overview template.`, executeError.Error())
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityCritical, LM.ImpactCritical, LM.MessageNameEXECUTE, `Was not able to execute the admin's overview template.`, executeError.Error())
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,12 @@ import (
|
|||||||
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
"github.com/SommerEngineering/Ocean/ConfigurationDB"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
// Data for the admin's configuration management site
|
||||||
type AdminWebConfiguration struct {
|
type AdminWebConfiguration struct {
|
||||||
Configuration []ConfigurationDB.ConfigurationDBEntry
|
Configuration []ConfigurationDB.ConfigurationDBEntry
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Data for the admin's overview i.e. dashboard
|
||||||
|
type AdminWebOverview struct {
|
||||||
|
Version string
|
||||||
|
}
|
||||||
|
@ -29,6 +29,7 @@ var Overview = `
|
|||||||
<div class="w-col w-col-4"><a class="button adminbutton" href="/configuration">Configuration</a>
|
<div class="w-col w-col-4"><a class="button adminbutton" href="/configuration">Configuration</a>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
<div class="admintextblock">The current Ocean's version is: {{.Version}}</div>
|
||||||
</div>
|
</div>
|
||||||
<script type="text/javascript" src="/admin/js/jquery.min.js"></script>
|
<script type="text/javascript" src="/admin/js/jquery.min.js"></script>
|
||||||
<script type="text/javascript" src="/admin/js/webflow.js"></script>
|
<script type="text/javascript" src="/admin/js/webflow.js"></script>
|
||||||
|
44
ICCC/ICCCGetVersionReceiver.go
Normal file
44
ICCC/ICCCGetVersionReceiver.go
Normal file
@ -0,0 +1,44 @@
|
|||||||
|
package ICCC
|
||||||
|
|
||||||
|
import (
|
||||||
|
"github.com/SommerEngineering/Ocean/ICCC/SystemMessages"
|
||||||
|
"github.com/SommerEngineering/Ocean/Log"
|
||||||
|
LM "github.com/SommerEngineering/Ocean/Log/Meta"
|
||||||
|
"github.com/SommerEngineering/Ocean/System/Version"
|
||||||
|
"github.com/SommerEngineering/Ocean/Tools"
|
||||||
|
)
|
||||||
|
|
||||||
|
// The receiver function for the ICCC version message.
|
||||||
|
func ICCCGetVersionReceiver(data map[string][]string) (result map[string][]string) {
|
||||||
|
|
||||||
|
// Recover from errors:
|
||||||
|
defer func() {
|
||||||
|
if err := recover(); err != nil {
|
||||||
|
Log.LogFull(senderName, LM.CategorySYSTEM, LM.LevelERROR, LM.SeverityUnknown, LM.ImpactUnknown, LM.MessageNamePARSE, "Was not able to execute the ICCC get version message.")
|
||||||
|
result = make(map[string][]string, 0)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
}()
|
||||||
|
|
||||||
|
// Converts the HTTP form data into an object:
|
||||||
|
_, _, obj := Data2Message(SystemMessages.ICCCGetVersion{}, data)
|
||||||
|
|
||||||
|
// Was it possible to convert the data?
|
||||||
|
if obj != nil {
|
||||||
|
|
||||||
|
// Prepare the answer:
|
||||||
|
answer := SystemMessages.ICCCGetVersionAnswer{}
|
||||||
|
answer.Kind = `Ocean`
|
||||||
|
answer.Name = Tools.ThisHostname()
|
||||||
|
answer.Version = Version.GetVersion()
|
||||||
|
|
||||||
|
// An answer is necessary:
|
||||||
|
return Message2Data("", "", answer)
|
||||||
|
} else {
|
||||||
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `ICCC message: Was not able to convert the ping message.`)
|
||||||
|
}
|
||||||
|
|
||||||
|
// In any other error case:
|
||||||
|
result = make(map[string][]string, 0)
|
||||||
|
return
|
||||||
|
}
|
12
ICCC/SystemMessages/ICCCGetVersion.go
Normal file
12
ICCC/SystemMessages/ICCCGetVersion.go
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package SystemMessages
|
||||||
|
|
||||||
|
// Requests the version from a Ocean server
|
||||||
|
type ICCCGetVersion struct {
|
||||||
|
}
|
||||||
|
|
||||||
|
// Answer to the version request
|
||||||
|
type ICCCGetVersionAnswer struct {
|
||||||
|
Kind string // Ocean || Component
|
||||||
|
Name string // Ocean: Hostname; Components: Name
|
||||||
|
Version string // The current version
|
||||||
|
}
|
@ -4,9 +4,12 @@ package SystemMessages
|
|||||||
type ICCCOceanStartUpMessage struct {
|
type ICCCOceanStartUpMessage struct {
|
||||||
PublicIPAddressPort string // The public web server's IP address and port
|
PublicIPAddressPort string // The public web server's IP address and port
|
||||||
AdminIPAddressPort string // The private admin server's IP address and port
|
AdminIPAddressPort string // The private admin server's IP address and port
|
||||||
|
OceanVersion string // The current version of this server
|
||||||
}
|
}
|
||||||
|
|
||||||
// Message type for a startup message for external components:
|
// Message type for a startup message for external components:
|
||||||
type ICCCComponentStartUpMessage struct {
|
type ICCCComponentStartUpMessage struct {
|
||||||
IPAddressPort string // The component's ICCC IP address and port
|
IPAddressPort string // The component's ICCC IP address and port
|
||||||
|
Name string // What is the name of this component?
|
||||||
|
Version string // Which version is used?
|
||||||
}
|
}
|
||||||
|
@ -14,6 +14,7 @@ const (
|
|||||||
ChannelSHUTDOWN string = `System::Shutdown` // A channel for system shutdown messages.
|
ChannelSHUTDOWN string = `System::Shutdown` // A channel for system shutdown messages.
|
||||||
ChannelSTARTUP string = `System::Startup` // A channel for system startup messages.
|
ChannelSTARTUP string = `System::Startup` // A channel for system startup messages.
|
||||||
ChannelICCC string = `System::ICCC` // A common ICCC channel.
|
ChannelICCC string = `System::ICCC` // A common ICCC channel.
|
||||||
|
ChannelPING string = `System::Ping` // A channel for pings.
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
@ -29,7 +29,7 @@ func icccComponentStartUpMessageReceiver(data map[string][]string) (result map[s
|
|||||||
messageData := obj.(SystemMessages.ICCCComponentStartUpMessage)
|
messageData := obj.(SystemMessages.ICCCComponentStartUpMessage)
|
||||||
|
|
||||||
// Provide a log entry:
|
// Provide a log entry:
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `ICCC message: The external component is now up and ready.`, fmt.Sprintf("ipAddressPort=%s", messageData.IPAddressPort))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `ICCC message: The external component is now up and ready.`, fmt.Sprintf("ipAddressPort=%s", messageData.IPAddressPort), fmt.Sprintf("name=", messageData.Name), fmt.Sprintf("version=", messageData.Version))
|
||||||
|
|
||||||
// An answer is necessary:
|
// An answer is necessary:
|
||||||
return ICCC.Message2Data("", "", SystemMessages.AnswerACK)
|
return ICCC.Message2Data("", "", SystemMessages.AnswerACK)
|
||||||
|
@ -29,7 +29,7 @@ func icccOceanStartUpMessageReceiver(data map[string][]string) (result map[strin
|
|||||||
messageData := obj.(SystemMessages.ICCCOceanStartUpMessage)
|
messageData := obj.(SystemMessages.ICCCOceanStartUpMessage)
|
||||||
|
|
||||||
// Provide a log entry:
|
// Provide a log entry:
|
||||||
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `ICCC message: The Ocean server is now up and ready.`, fmt.Sprintf("public server=%s", messageData.PublicIPAddressPort), fmt.Sprintf("admin server=%s", messageData.AdminIPAddressPort))
|
Log.LogShort(senderName, LM.CategorySYSTEM, LM.LevelINFO, LM.MessageNameSTARTUP, `ICCC message: The Ocean server is now up and ready.`, fmt.Sprintf("public server=%s", messageData.PublicIPAddressPort), fmt.Sprintf("admin server=%s", messageData.AdminIPAddressPort), fmt.Sprintf("Ocean's version=%s", messageData.OceanVersion))
|
||||||
|
|
||||||
// An answer is necessary:
|
// An answer is necessary:
|
||||||
return ICCC.Message2Data("", "", SystemMessages.AnswerACK)
|
return ICCC.Message2Data("", "", SystemMessages.AnswerACK)
|
||||||
|
@ -11,6 +11,7 @@ import (
|
|||||||
"github.com/SommerEngineering/Ocean/Log/Web"
|
"github.com/SommerEngineering/Ocean/Log/Web"
|
||||||
"github.com/SommerEngineering/Ocean/Robots"
|
"github.com/SommerEngineering/Ocean/Robots"
|
||||||
"github.com/SommerEngineering/Ocean/StaticFiles"
|
"github.com/SommerEngineering/Ocean/StaticFiles"
|
||||||
|
"github.com/SommerEngineering/Ocean/System/Version"
|
||||||
"github.com/SommerEngineering/Ocean/WebContent"
|
"github.com/SommerEngineering/Ocean/WebContent"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -58,6 +59,9 @@ func InitHandlers() {
|
|||||||
// Handler for the web logging:
|
// Handler for the web logging:
|
||||||
Handlers.AddAdminHandler(`/log`, Web.HandlerWebLog)
|
Handlers.AddAdminHandler(`/log`, Web.HandlerWebLog)
|
||||||
|
|
||||||
|
// Handler for the access to Ocean's version:
|
||||||
|
Handlers.AddAdminHandler(`/version`, Version.HandlerVersion)
|
||||||
|
|
||||||
// Handler for the file upload:
|
// Handler for the file upload:
|
||||||
Handlers.AddAdminHandler(`/upload`, Admin.HandlerFileUpload)
|
Handlers.AddAdminHandler(`/upload`, Admin.HandlerFileUpload)
|
||||||
|
|
||||||
|
@ -104,7 +104,8 @@ func initSystem() {
|
|||||||
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::DeleteListener`, ICCC.ICCCDeleteListenerReceiver)
|
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::DeleteListener`, ICCC.ICCCDeleteListenerReceiver)
|
||||||
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::DeleteHost`, ICCC.ICCCDeleteHostReceiver)
|
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::DeleteHost`, ICCC.ICCCDeleteHostReceiver)
|
||||||
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::ListenerUpdate`, ICCC.ICCCListenerUpdateReceiver)
|
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::ListenerUpdate`, ICCC.ICCCListenerUpdateReceiver)
|
||||||
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::Ping`, ICCC.ICCCPingReceiver)
|
ICCC.Registrar(ICCC.ChannelICCC, `Ping::Ping`, ICCC.ICCCPingReceiver)
|
||||||
|
ICCC.Registrar(ICCC.ChannelSYSTEM, `System::Version`, ICCC.ICCCGetVersionReceiver)
|
||||||
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::GetHosts`, ICCC.ICCCGetHostsReceiver)
|
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::GetHosts`, ICCC.ICCCGetHostsReceiver)
|
||||||
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::GetListeners`, ICCC.ICCCGetListenersReceiver)
|
ICCC.Registrar(ICCC.ChannelICCC, `ICCC::GetListeners`, ICCC.ICCCGetListenersReceiver)
|
||||||
ICCC.Registrar(ICCC.ChannelNUMGEN, `NumGen::Next`, NumGen.ICCCNextNumberReceiver)
|
ICCC.Registrar(ICCC.ChannelNUMGEN, `NumGen::Next`, NumGen.ICCCNextNumberReceiver)
|
||||||
|
6
System/Version/GetVersion.go
Normal file
6
System/Version/GetVersion.go
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
package Version
|
||||||
|
|
||||||
|
// Gets Ocean's version
|
||||||
|
func GetVersion() string {
|
||||||
|
return oceansVersion
|
||||||
|
}
|
19
System/Version/HandlerVersion.go
Normal file
19
System/Version/HandlerVersion.go
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
package Version
|
||||||
|
|
||||||
|
import (
|
||||||
|
"fmt"
|
||||||
|
"github.com/SommerEngineering/Ocean/Shutdown"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
// Handler for the access to Ocean's version
|
||||||
|
func HandlerVersion(response http.ResponseWriter, request *http.Request) {
|
||||||
|
|
||||||
|
// Case: The system goes down now?
|
||||||
|
if Shutdown.IsDown() {
|
||||||
|
http.NotFound(response, request)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
fmt.Fprintf(response, "%s", oceansVersion)
|
||||||
|
}
|
5
System/Version/Variables.go
Normal file
5
System/Version/Variables.go
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
package Version
|
||||||
|
|
||||||
|
var (
|
||||||
|
oceansVersion string = `2.0.0` // Ocean's current version
|
||||||
|
)
|
@ -6,12 +6,14 @@ import (
|
|||||||
"github.com/SommerEngineering/Ocean/ICCC/SystemMessages"
|
"github.com/SommerEngineering/Ocean/ICCC/SystemMessages"
|
||||||
"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/System/Version"
|
||||||
)
|
)
|
||||||
|
|
||||||
func Start() {
|
func Start() {
|
||||||
|
|
||||||
// Tell the whole cluster, that we are up and ready:
|
// Tell the whole cluster, that we are up and ready:
|
||||||
data := SystemMessages.ICCCOceanStartUpMessage{}
|
data := SystemMessages.ICCCOceanStartUpMessage{}
|
||||||
|
data.OceanVersion = Version.GetVersion()
|
||||||
|
|
||||||
// Start the public web server:
|
// Start the public web server:
|
||||||
if serverPublic != nil {
|
if serverPublic != nil {
|
||||||
|
Loading…
Reference in New Issue
Block a user