Skip to content

Commit

Permalink
Introduces version string in log message
Browse files Browse the repository at this point in the history
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
  • Loading branch information
ThomasLeister committed Apr 20, 2020
1 parent 016ffd9 commit 07d0882
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 6 deletions.
13 changes: 8 additions & 5 deletions build.sh
Original file line number Diff line number Diff line change
@@ -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"' .
3 changes: 2 additions & 1 deletion main.go → prosody-filer.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ type Config struct {
}

var conf Config
var versionString string = "0.0.0"

/*
* Sets CORS headers
Expand Down Expand Up @@ -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)
Expand Down
File renamed without changes.

0 comments on commit 07d0882

Please sign in to comment.