add some info to exe
This commit is contained in:
parent
e1e6e2cbc2
commit
5c3a646918
|
@ -1,4 +1,11 @@
|
||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
|
|
||||||
|
if [ -z ${1+x} ]; then
|
||||||
|
VERSION="0.0.0"
|
||||||
|
else
|
||||||
|
VERSION="$1"
|
||||||
|
fi
|
||||||
|
|
||||||
mkdir -p ../dist
|
mkdir -p ../dist
|
||||||
go build -v -trimpath -ldflags "-s -w" -tags "$(date -u)" -o ../dist/crazyfs
|
go build -v -trimpath -ldflags "-s -w -X main.VersionDate=$(date -u --iso-8601=minutes) -X main.Version=v$VERSION" -o ../dist/crazyfs
|
|
@ -16,6 +16,7 @@ import (
|
||||||
"net/http"
|
"net/http"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
"runtime/debug"
|
||||||
"time"
|
"time"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -27,8 +28,12 @@ type cliConfig struct {
|
||||||
debug bool
|
debug bool
|
||||||
disableElasticSync bool
|
disableElasticSync bool
|
||||||
help bool
|
help bool
|
||||||
|
version bool
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var Version = "development"
|
||||||
|
var VersionDate = "not set"
|
||||||
|
|
||||||
// TODO: optional serving of frontend
|
// TODO: optional serving of frontend
|
||||||
// TODO: admin api to clear cache, get number of items in cache, get memory usage
|
// TODO: admin api to clear cache, get number of items in cache, get memory usage
|
||||||
// TODO: health api endpoint that tells us if the server is still starting
|
// TODO: health api endpoint that tells us if the server is still starting
|
||||||
|
@ -37,13 +42,31 @@ type cliConfig struct {
|
||||||
// TODO: admin api endpoint to get status and progress of the full refresh of elasticsearch
|
// TODO: admin api endpoint to get status and progress of the full refresh of elasticsearch
|
||||||
|
|
||||||
func main() {
|
func main() {
|
||||||
|
fmt.Println("=== Crazy File Server ===")
|
||||||
cliArgs := parseArgs()
|
cliArgs := parseArgs()
|
||||||
if cliArgs.help {
|
if cliArgs.help {
|
||||||
flag.Usage()
|
flag.Usage()
|
||||||
os.Exit(0)
|
os.Exit(0)
|
||||||
}
|
}
|
||||||
|
if cliArgs.version {
|
||||||
|
buildInfo, ok := debug.ReadBuildInfo()
|
||||||
|
|
||||||
|
if ok {
|
||||||
|
buildSettings := make(map[string]string)
|
||||||
|
for i := range buildInfo.Settings {
|
||||||
|
buildSettings[buildInfo.Settings[i].Key] = buildInfo.Settings[i].Value
|
||||||
|
}
|
||||||
|
fmt.Printf("Version: %s\n\n", Version)
|
||||||
|
fmt.Printf("Date Compiled: %s\n", VersionDate)
|
||||||
|
fmt.Printf("Git Revision: %s\n", buildSettings["vcs.revision"])
|
||||||
|
fmt.Printf("Git Revision Date: %s\n", buildSettings["vcs.time"])
|
||||||
|
fmt.Printf("Git Modified: %s\n", buildSettings["vcs.modified"])
|
||||||
|
} else {
|
||||||
|
fmt.Println("Build info not available")
|
||||||
|
}
|
||||||
|
os.Exit(0)
|
||||||
|
}
|
||||||
|
|
||||||
fmt.Println("=== Crazy File Server ===")
|
|
||||||
if cliArgs.debug {
|
if cliArgs.debug {
|
||||||
logging.InitLogger(logrus.DebugLevel)
|
logging.InitLogger(logrus.DebugLevel)
|
||||||
} else {
|
} else {
|
||||||
|
@ -163,12 +186,13 @@ func main() {
|
||||||
|
|
||||||
func parseArgs() cliConfig {
|
func parseArgs() cliConfig {
|
||||||
var cliArgs cliConfig
|
var cliArgs cliConfig
|
||||||
flag.StringVar(&cliArgs.configFile, "config", "", "StartPath to the config file")
|
flag.StringVar(&cliArgs.configFile, "config", "", "Path to the config file")
|
||||||
flag.BoolVar(&cliArgs.initialCrawl, "initial-crawl", false, "Do an initial crawl to fill the cache")
|
flag.BoolVar(&cliArgs.initialCrawl, "initial-crawl", false, "Do an initial crawl to fill the cache")
|
||||||
flag.BoolVar(&cliArgs.initialCrawl, "i", false, "Do an initial crawl to fill the cache")
|
flag.BoolVar(&cliArgs.initialCrawl, "i", false, "Do an initial crawl to fill the cache")
|
||||||
flag.BoolVar(&cliArgs.debug, "d", false, "Enable debug mode")
|
flag.BoolVar(&cliArgs.debug, "d", false, "Enable debug mode")
|
||||||
flag.BoolVar(&cliArgs.debug, "debug", false, "Enable debug mode")
|
flag.BoolVar(&cliArgs.debug, "debug", false, "Enable debug mode")
|
||||||
flag.BoolVar(&cliArgs.disableElasticSync, "disable-elastic-sync", false, "Disable the Elasticsearch background sync thread")
|
flag.BoolVar(&cliArgs.disableElasticSync, "disable-elastic-sync", false, "Disable the Elasticsearch background sync thread")
|
||||||
|
flag.BoolVar(&cliArgs.version, "v", false, "Print version and exit")
|
||||||
flag.Parse()
|
flag.Parse()
|
||||||
return cliArgs
|
return cliArgs
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue