more work on tracking on the version bulid time
Signed-off-by: Jeff Carr <jcarr@wit.com>
This commit is contained in:
parent
2768e0f278
commit
47e169d2ba
|
@ -6,6 +6,7 @@
|
||||||
# built. what version was built, etc
|
# built. what version was built, etc
|
||||||
# TODO: find a better way (not via ldflags)
|
# TODO: find a better way (not via ldflags)
|
||||||
resources/build
|
resources/build
|
||||||
|
resources/BUILDDATE
|
||||||
|
|
||||||
cloud-control-panel
|
cloud-control-panel
|
||||||
|
|
||||||
|
|
4
Makefile
4
Makefile
|
@ -48,7 +48,9 @@ tag-version:
|
||||||
git tag v${VERSION}
|
git tag v${VERSION}
|
||||||
git push --tags
|
git push --tags
|
||||||
# https://mirrors.wit.com/cloud/control-panel/
|
# https://mirrors.wit.com/cloud/control-panel/
|
||||||
scp VERSION root@mirrors.wit.com:/data/mirrors/cloud/control-panel/
|
scp VERSION root@mirrors.wit.com:/data/mirrors/cloud/control-panel/linux/
|
||||||
|
# date +%s > resources/BUILDDATE
|
||||||
|
scp resources/BUILDDATE root@mirrors.wit.com:/data/mirrors/cloud/control-panel/linux/
|
||||||
scp README root@mirrors.wit.com:/data/mirrors/cloud/control-panel/
|
scp README root@mirrors.wit.com:/data/mirrors/cloud/control-panel/
|
||||||
|
|
||||||
# should update every go dependancy (?)
|
# should update every go dependancy (?)
|
||||||
|
|
|
@ -252,7 +252,7 @@ func parseConfig() {
|
||||||
config.Dirty = true
|
config.Dirty = true
|
||||||
}
|
}
|
||||||
|
|
||||||
buf, _ := wget("https://mirrors.wit.com/cloud/control-panel/VERSION")
|
buf := wget("https://mirrors.wit.com/cloud/control-panel/VERSION")
|
||||||
upstream := shell.Chomp(buf)
|
upstream := shell.Chomp(buf)
|
||||||
|
|
||||||
epoch := shell.Run("git log -1 --format=%at v" + version)
|
epoch := shell.Run("git log -1 --format=%at v" + version)
|
||||||
|
@ -297,6 +297,8 @@ func parseConfig() {
|
||||||
// my pid (cross platform) p, err := os.FindProcess(os.Getpid())
|
// my pid (cross platform) p, err := os.FindProcess(os.Getpid())
|
||||||
// send signal (cross platform) return p.Signal(syscall.SIGTERM)
|
// send signal (cross platform) return p.Signal(syscall.SIGTERM)
|
||||||
|
|
||||||
|
update()
|
||||||
|
|
||||||
// for {}
|
// for {}
|
||||||
// os.Exit(0)
|
// os.Exit(0)
|
||||||
}
|
}
|
||||||
|
|
|
@ -0,0 +1,71 @@
|
||||||
|
package main
|
||||||
|
|
||||||
|
/*
|
||||||
|
This simply parses the command line arguments using the default golang
|
||||||
|
package called 'flag'. This can be used as a simple template to parse
|
||||||
|
command line arguments in other programs.
|
||||||
|
|
||||||
|
It puts everything in a 'config' Protobuf which I think is a good
|
||||||
|
wrapper around the 'flags' package and doesn't need a whole mess of
|
||||||
|
global variables
|
||||||
|
*/
|
||||||
|
|
||||||
|
import "log"
|
||||||
|
import "time"
|
||||||
|
import "runtime"
|
||||||
|
// import "os"
|
||||||
|
// import "os/user"
|
||||||
|
// import "flag"
|
||||||
|
// import "fmt"
|
||||||
|
// import "runtime/debug"
|
||||||
|
// import "io/ioutil"
|
||||||
|
// import "strings"
|
||||||
|
// import "reflect"
|
||||||
|
// import "bytes"
|
||||||
|
// import "sys"
|
||||||
|
|
||||||
|
// import "github.com/golang/protobuf/jsonpb"
|
||||||
|
// import pb "git.wit.com/wit/witProtobuf"
|
||||||
|
import "git.wit.com/wit/shell"
|
||||||
|
|
||||||
|
// import "github.com/davecgh/go-spew/spew"
|
||||||
|
|
||||||
|
//
|
||||||
|
// This is what you call from main()
|
||||||
|
//
|
||||||
|
func update() {
|
||||||
|
version := shell.Run("cat VERSION")
|
||||||
|
|
||||||
|
mirrorsBUILDDATE := shell.Chomp(wget("https://mirrors.wit.com/cloud/control-panel/linux/BUILDDATE"))
|
||||||
|
upstream := shell.Chomp(wget("https://mirrors.wit.com/cloud/control-panel/linux/VERSION"))
|
||||||
|
upstreamEpoch := shell.Run("git log -1 --format=%at v" + upstream)
|
||||||
|
epoch := time.Now().Unix()
|
||||||
|
|
||||||
|
myBUILDDATE, _ := packrBox.FindString("BUILDDATE")
|
||||||
|
|
||||||
|
if (! config.Dirty) {
|
||||||
|
// See if a newer version of this control panel exists
|
||||||
|
// if (epoch > time.now().Unix()) // seconds since epoch
|
||||||
|
}
|
||||||
|
|
||||||
|
log.Println()
|
||||||
|
log.Println("version =", version)
|
||||||
|
log.Println("upstream =", upstream)
|
||||||
|
log.Println("now() =", epoch)
|
||||||
|
log.Println("myBUILDDATE =", myBUILDDATE)
|
||||||
|
log.Println("upstreamEpoch =", upstreamEpoch)
|
||||||
|
log.Println("mirrorsBUILDDATE =", mirrorsBUILDDATE)
|
||||||
|
log.Println()
|
||||||
|
log.Println("config.Gitref =", config.Gitref)
|
||||||
|
log.Println("config.Goversion =", config.Goversion)
|
||||||
|
log.Println("config.Dirty =", config.Dirty)
|
||||||
|
log.Println()
|
||||||
|
log.Println("runtime.Version =", runtime.Version())
|
||||||
|
log.Println("Number of CPUs =", runtime.NumCPU())
|
||||||
|
log.Println("Number of GoRoutines =", runtime.NumGoroutine())
|
||||||
|
log.Println("runtime.GOARCH =", runtime.GOARCH)
|
||||||
|
log.Println()
|
||||||
|
|
||||||
|
for {}
|
||||||
|
// os.Exit(0)
|
||||||
|
}
|
20
wget.go
20
wget.go
|
@ -16,35 +16,23 @@ import "bytes"
|
||||||
import "io"
|
import "io"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
import "log"
|
|
||||||
import "os/user"
|
|
||||||
import "flag"
|
|
||||||
import "fmt"
|
|
||||||
import "runtime"
|
|
||||||
import "strings"
|
|
||||||
import "reflect"
|
|
||||||
|
|
||||||
import "github.com/golang/protobuf/jsonpb"
|
|
||||||
import pb "git.wit.com/wit/witProtobuf"
|
|
||||||
import "git.wit.com/wit/shell"
|
import "git.wit.com/wit/shell"
|
||||||
|
|
||||||
import "github.com/davecgh/go-spew/spew"
|
import "github.com/davecgh/go-spew/spew"
|
||||||
*/
|
*/
|
||||||
|
|
||||||
func wget(url string) (*bytes.Buffer, error) {
|
func wget(url string) (*bytes.Buffer) {
|
||||||
buf := new(bytes.Buffer)
|
buf := new(bytes.Buffer)
|
||||||
|
|
||||||
// Get the data
|
// Get the data
|
||||||
resp, err := http.Get(url)
|
resp, err := http.Get(url)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return buf, err
|
errChan <- err
|
||||||
|
return buf
|
||||||
}
|
}
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
buf.ReadFrom(resp.Body)
|
buf.ReadFrom(resp.Body)
|
||||||
// newStr := buf.String()
|
return buf
|
||||||
// tmp := string(resp.Body)
|
|
||||||
return buf, err
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func wgetToFile(filepath string, url string) error {
|
func wgetToFile(filepath string, url string) error {
|
||||||
|
|
Loading…
Reference in New Issue