Skip to content

Commit

Permalink
Merge pull request #649 from smartystreets/serverVersion
Browse files Browse the repository at this point in the history
Report server version on startup.
  • Loading branch information
riannucci committed Oct 28, 2021
2 parents 2fa2eeb + 13a1c07 commit 6119263
Showing 1 changed file with 23 additions and 5 deletions.
28 changes: 23 additions & 5 deletions goconvey.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
package main

import (
"context"
"embed"
"flag"
"fmt"
Expand All @@ -18,6 +19,7 @@ import (
"os/signal"
"path/filepath"
"runtime"
"runtime/debug"
"strings"
"syscall"
"time"
Expand Down Expand Up @@ -54,7 +56,8 @@ func init() {

func main() {
flag.Parse()
log.Printf(initialConfiguration, host, port, nap, cover)

printHeader()

tmpDir, err := ioutil.TempDir("", "*.goconvey")
if err != nil {
Expand Down Expand Up @@ -102,11 +105,27 @@ func main() {

<-done
log.Println("shutting down")
if err := srv.Shutdown(nil); err != nil {
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()
if err := srv.Shutdown(ctx); err != nil {
log.Printf("failed to shutdown: %s\n", err)
}
}

func printHeader() {
log.Println("GoConvey server: ")
serverVersion := "<unknown>"
if binfo, ok := debug.ReadBuildInfo(); ok {
serverVersion = binfo.Main.Version
}
log.Println(" version:", serverVersion)
log.Println(" host:", host)
log.Println(" port:", port)
log.Println(" poll:", nap)
log.Println(" cover:", cover)
log.Println()
}

func browserCmd() (string, bool) {
browser := map[string]string{
"darwin": "open",
Expand Down Expand Up @@ -283,9 +302,8 @@ var (
)

const (
initialConfiguration = "Initial configuration: [host: %s] [port: %d] [poll: %v] [cover: %v]\n"
separator = string(filepath.Separator)
endGoPath = separator + "src" + separator
separator = string(filepath.Separator)
endGoPath = separator + "src" + separator
)

// This method exists because of a bug in the go cover tool that
Expand Down

0 comments on commit 6119263

Please sign in to comment.