minor reorg

This commit is contained in:
Jeffrey Paul 2019-10-29 11:48:53 -07:00
parent 055abf8149
commit 92335ead98
3 changed files with 38 additions and 19 deletions

View File

@ -2,8 +2,6 @@ package main
import (
"context"
"fmt"
"github.com/rs/zerolog/log"
"time"
//"github.com/bitly/go-simplejson"
)
@ -27,11 +25,10 @@ func (a *Archiver) Uptime() time.Duration {
return time.Since(*a.startup)
}
func (a *Archiver) Run() int {
func (a *Archiver) RunForever() int {
t := time.Now()
a.startup = &t
a.locator = NewInstanceLocator()
log.Info().Msg(fmt.Sprintf("in %#v.Run()", a))
go a.locator.Locate()
for {

36
identity.go Normal file
View File

@ -0,0 +1,36 @@
package main
import (
"github.com/rs/zerolog/log"
)
var Version string
var Buildtime string
var Builduser string
var Buildarch string
type AppIdentity struct {
Version string
Buildtime string
Builduser string
Buildarch string
}
func GetAppIdentity() *AppIdentity {
i := new(AppIdentity)
i.Version = Version
i.Buildtime = Buildtime
i.Builduser = Builduser
i.Buildarch = Buildarch
return i
}
func identify() {
i := GetAppIdentity()
log.Info().
Str("version", i.Version).
Str("buildarch", i.Buildarch).
Str("buildtime", i.Buildtime).
Str("builduser", i.Builduser).
Msg("starting")
}

16
main.go
View File

@ -9,24 +9,10 @@ import (
"os"
)
var Version string
var Buildtime string
var Builduser string
var Buildarch string
func main() {
os.Exit(app())
}
func identify() {
log.Info().
Str("version", Version).
Str("buildarch", Buildarch).
Str("buildtime", Buildtime).
Str("builduser", Builduser).
Msg("starting")
}
func app() int {
log.Logger = log.With().Caller().Logger()
if terminal.IsTerminal(int(os.Stdout.Fd())) {
@ -44,5 +30,5 @@ func app() int {
}
mainContext := context.Background()
return NewArchiver(mainContext).Run()
return NewArchiver(mainContext).RunForever()
}