From 07d0882c657fbe5fbaa9f366e32b04f9cf62ed94 Mon Sep 17 00:00:00 2001 From: Thomas Leister Date: Mon, 20 Apr 2020 21:20:39 +0200 Subject: [PATCH] Introduces version string in log message Adds a version string to enable the user to distinguish between multiple Prosody-Filer versions. The version information is "baked in" via the linker in build.sh --- build.sh | 13 ++++++++----- main.go => prosody-filer.go | 3 ++- main_test.go => prosody-filer_test.go | 0 3 files changed, 10 insertions(+), 6 deletions(-) rename main.go => prosody-filer.go (98%) rename main_test.go => prosody-filer_test.go (100%) diff --git a/build.sh b/build.sh index f6a41e9..b168008 100755 --- a/build.sh +++ b/build.sh @@ -1,7 +1,10 @@ -#!/bin/sh +#!/bin/bash -## -## Builds static prosody-filer binary -## +### get VERSIONSTRING +VERSIONSTRING="$(git describe --tags --exact-match || git rev-parse --short HEAD)" + +echo "Building version ${VERSIONSTRING} of Prosody-Filer ..." + +### Compile and link statically +CGO_ENABLED=0 GOOS=linux go build -a -ldflags "-extldflags '-static' -w -s -X main.versionString=${VERSIONSTRING}" prosody-filer.go -CGO_ENABLED=0 GOOS=linux go build -a -ldflags '-extldflags "-static"' . diff --git a/main.go b/prosody-filer.go similarity index 98% rename from main.go rename to prosody-filer.go index 9e9d6c2..7bf9c8c 100644 --- a/main.go +++ b/prosody-filer.go @@ -36,6 +36,7 @@ type Config struct { } var conf Config +var versionString string = "0.0.0" /* * Sets CORS headers @@ -192,7 +193,7 @@ func main() { /* * Start HTTP server */ - log.Println("Starting up XMPP HTTP upload server ...") + log.Println("Starting Prosody-Filer", versionString, "...") http.HandleFunc("/"+conf.UploadSubDir, handleRequest) log.Printf("Server started on port %s. Waiting for requests.\n", conf.Listenport) http.ListenAndServe(conf.Listenport, nil) diff --git a/main_test.go b/prosody-filer_test.go similarity index 100% rename from main_test.go rename to prosody-filer_test.go