Add version information for tusd builds

This commit is contained in:
Marius 2016-01-23 12:43:50 +01:00
parent 0e750291c9
commit 2a84435974
2 changed files with 14 additions and 1 deletions

View File

@ -28,7 +28,7 @@ before_deploy:
- export GOROOT_BOOTSTRAP=$GOROOT - export GOROOT_BOOTSTRAP=$GOROOT
- go get github.com/laher/goxc - go get github.com/laher/goxc
- goxc -t -bc="linux darwin windows" - goxc -t -bc="linux darwin windows"
- goxc -d=./ -wd=./cmd/tusd -bc="linux darwin windows" - goxc -d=./ -wd=./cmd/tusd -bc="linux darwin windows" -ldflags="-X main.VersionName=$TRAVIS_TAG -X main.GitCommit=$TRAVIS_COMMIT -X 'main.BuildDate=$(date --utc)'"
deploy: deploy:
provider: releases provider: releases

View File

@ -7,6 +7,7 @@ import (
"net/http" "net/http"
"os" "os"
"time" "time"
"fmt"
"github.com/tus/tusd" "github.com/tus/tusd"
"github.com/tus/tusd/filestore" "github.com/tus/tusd/filestore"
@ -19,6 +20,10 @@ import (
"github.com/aws/aws-sdk-go/aws" "github.com/aws/aws-sdk-go/aws"
) )
var VersionName = "n/a"
var GitCommit = "n/a"
var BuildDate = "n/a"
var httpHost string var httpHost string
var httpPort string var httpPort string
var maxSize int64 var maxSize int64
@ -27,6 +32,7 @@ var storeSize int64
var basepath string var basepath string
var timeout int64 var timeout int64
var s3Bucket string var s3Bucket string
var version bool
var stdout = log.New(os.Stdout, "[tusd] ", 0) var stdout = log.New(os.Stdout, "[tusd] ", 0)
var stderr = log.New(os.Stderr, "[tusd] ", 0) var stderr = log.New(os.Stderr, "[tusd] ", 0)
@ -40,11 +46,18 @@ func init() {
flag.StringVar(&basepath, "base-path", "/files/", "Basepath of the HTTP server") flag.StringVar(&basepath, "base-path", "/files/", "Basepath of the HTTP server")
flag.Int64Var(&timeout, "timeout", 30*1000, "Read timeout for connections in milliseconds") flag.Int64Var(&timeout, "timeout", 30*1000, "Read timeout for connections in milliseconds")
flag.StringVar(&s3Bucket, "s3-bucket", "", "Use AWS S3 with this bucket as storage backend (requires the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION environment variables to be set)") flag.StringVar(&s3Bucket, "s3-bucket", "", "Use AWS S3 with this bucket as storage backend (requires the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY and AWS_REGION environment variables to be set)")
flag.BoolVar(&version, "version", false, "Print tusd version information")
flag.Parse() flag.Parse()
} }
func main() { func main() {
if version {
fmt.Printf("Version: %s\nCommit: %s\nDate: %s\n", VersionName, GitCommit, BuildDate)
return
}
var store tusd.TerminaterDataStore var store tusd.TerminaterDataStore
if s3Bucket == "" { if s3Bucket == "" {
stdout.Printf("Using '%s' as directory storage.\n", dir) stdout.Printf("Using '%s' as directory storage.\n", dir)