XXX
This commit is contained in:
parent
13929eb7f9
commit
99d5815052
3 changed files with 21 additions and 11 deletions
|
@ -1,9 +1,14 @@
|
||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
|
|
||||||
"git.smsvc.net/pomodoro/GoTomato/cmd/server"
|
"git.smsvc.net/pomodoro/GoTomato/cmd/server"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
var Version = ""
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
fmt.Println(Version)
|
||||||
server.Start()
|
server.Start()
|
||||||
}
|
}
|
||||||
|
|
|
@ -28,7 +28,7 @@ func Start() {
|
||||||
|
|
||||||
// show server and protocl version and exit
|
// show server and protocl version and exit
|
||||||
if *showVersionFlag {
|
if *showVersionFlag {
|
||||||
fmt.Printf("GoTomato v%s\n", metadata.GoTomatoVersion)
|
fmt.Printf("GoTomato v%s\n", metadata.GetVersion())
|
||||||
fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion)
|
fmt.Printf("Protocol-Version: %s\n", metadata.ProtocolVersion)
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
@ -48,7 +48,7 @@ func Start() {
|
||||||
r.HandleFunc("/ws", websocket.HandleConnection)
|
r.HandleFunc("/ws", websocket.HandleConnection)
|
||||||
go websocket.SendPermanentBroadCastMessage()
|
go websocket.SendPermanentBroadCastMessage()
|
||||||
|
|
||||||
helper.Logger.Info("GoTomato started", "version", metadata.GoTomatoVersion)
|
helper.Logger.Info("GoTomato started", "version", metadata.GetVersion())
|
||||||
helper.Logger.Info("Websocket listening", "address", listen)
|
helper.Logger.Info("Websocket listening", "address", listen)
|
||||||
|
|
||||||
// start the listener
|
// start the listener
|
||||||
|
|
|
@ -1,20 +1,25 @@
|
||||||
package metadata
|
package metadata
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"os/exec"
|
"runtime/debug"
|
||||||
"strings"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
var (
|
var (
|
||||||
GoTomatoVersion = "" // The GoTomato version
|
version = ""
|
||||||
ProtocolVersion = "" // The protocol version
|
ProtocolVersion = "0"
|
||||||
)
|
)
|
||||||
|
|
||||||
func init() {
|
func init() {
|
||||||
if GoTomatoVersion == "" {
|
info, ok := debug.ReadBuildInfo()
|
||||||
output, _ := exec.Command("git", "describe", "--tags").Output()
|
if !ok || info.Main.Version == "" {
|
||||||
trimmed_output := strings.TrimSpace(string(output)) // strip newlines
|
version = "unknown"
|
||||||
GoTomatoVersion = strings.Replace(trimmed_output, "v", "", 1) // strip leading "v"
|
} else {
|
||||||
|
if version == "" {
|
||||||
|
version = info.Main.Version
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ProtocolVersion = strings.Split(GoTomatoVersion, ".")[0] // The protocol version
|
}
|
||||||
|
|
||||||
|
func GetVersion() string {
|
||||||
|
return version
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue