Merge pull request #272 from sosedoff/auto-open-when-running

Automatically open pgweb page if its already running
This commit is contained in:
Dan Sosedoff
2017-09-21 20:35:21 -05:00
committed by GitHub
+4
View File
@@ -5,6 +5,7 @@ import (
"os"
"os/exec"
"os/signal"
"strings"
"github.com/gin-gonic/gin"
"github.com/jessevdk/go-flags"
@@ -148,6 +149,9 @@ func startServer() {
err := router.Run(fmt.Sprintf("%v:%v", options.HttpHost, options.HttpPort))
if err != nil {
fmt.Println("Cant start server:", err)
if strings.Contains(err.Error(), "address already in use") {
openPage()
}
os.Exit(1)
}
}()