mirror of
https://github.com/kataras/iris.git
synced 2025-03-14 08:16:28 +01:00
iris run : Print the banner on every reload
This commit is contained in:
parent
e4038efb96
commit
1b3803e5c2
|
@ -1,7 +1,6 @@
|
||||||
package iris
|
package iris
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"flag"
|
|
||||||
"fmt"
|
"fmt"
|
||||||
"os"
|
"os"
|
||||||
"sync"
|
"sync"
|
||||||
|
@ -79,14 +78,6 @@ type Framework struct {
|
||||||
Websocket websocket.Server
|
Websocket websocket.Server
|
||||||
}
|
}
|
||||||
|
|
||||||
// SkipBannerFlag, if enabled then means that this instance ran propably by an external software, which can disable the banner output by the command line argument '-s'
|
|
||||||
var SkipBannerFlag bool
|
|
||||||
|
|
||||||
func init() {
|
|
||||||
flag.BoolVar(&SkipBannerFlag, "s", false, "Disable banner via command line tool, overrides the logger's config field") // this mostly used by the iris command line tool
|
|
||||||
flag.Parse()
|
|
||||||
}
|
|
||||||
|
|
||||||
// New creates and returns a new Iris station aka Framework.
|
// New creates and returns a new Iris station aka Framework.
|
||||||
//
|
//
|
||||||
// Receives an optional config.Iris as parameter
|
// Receives an optional config.Iris as parameter
|
||||||
|
@ -170,9 +161,7 @@ func (s *Framework) openServer() (err error) {
|
||||||
s.HTTPServer.SetHandler(s.mux)
|
s.HTTPServer.SetHandler(s.mux)
|
||||||
if err = s.HTTPServer.Open(); err == nil {
|
if err = s.HTTPServer.Open(); err == nil {
|
||||||
// print the banner
|
// print the banner
|
||||||
if s.Config.DisableBanner || SkipBannerFlag {
|
if !s.Config.DisableBanner {
|
||||||
// skip the banner
|
|
||||||
} else {
|
|
||||||
s.Logger.PrintBanner(banner,
|
s.Logger.PrintBanner(banner,
|
||||||
fmt.Sprintf("%s: Running at %s\n", time.Now().Format(config.TimeFormat),
|
fmt.Sprintf("%s: Running at %s\n", time.Now().Format(config.TimeFormat),
|
||||||
s.HTTPServer.Host()))
|
s.HTTPServer.Host()))
|
||||||
|
|
|
@ -14,6 +14,7 @@ import (
|
||||||
)
|
)
|
||||||
|
|
||||||
const (
|
const (
|
||||||
|
// Version of Iris command line tool
|
||||||
Version = "0.0.8"
|
Version = "0.0.8"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
@ -23,7 +23,7 @@ var (
|
||||||
goExt = ".go"
|
goExt = ".go"
|
||||||
)
|
)
|
||||||
|
|
||||||
var times uint32 = 0
|
var times uint32
|
||||||
|
|
||||||
func build(sourcepath string) error {
|
func build(sourcepath string) error {
|
||||||
goBuild := utils.CommandBuilder("go", "build", sourcepath)
|
goBuild := utils.CommandBuilder("go", "build", sourcepath)
|
||||||
|
@ -40,9 +40,7 @@ func build(sourcepath string) error {
|
||||||
|
|
||||||
func run(executablePath string) (*utils.Cmd, error) {
|
func run(executablePath string) (*utils.Cmd, error) {
|
||||||
runCmd := utils.CommandBuilder("." + utils.PathSeparator + executablePath)
|
runCmd := utils.CommandBuilder("." + utils.PathSeparator + executablePath)
|
||||||
if times >= 1 {
|
|
||||||
runCmd.AppendArguments("-s") //-s to skip the banner after the first time
|
|
||||||
}
|
|
||||||
runCmd.Dir = workingDir
|
runCmd.Dir = workingDir
|
||||||
runCmd.Stderr = os.Stderr
|
runCmd.Stderr = os.Stderr
|
||||||
runCmd.Stdout = os.Stdout
|
runCmd.Stdout = os.Stdout
|
||||||
|
@ -121,7 +119,7 @@ func runAndWatch(flags cli.Flags) error {
|
||||||
|
|
||||||
}, printer)
|
}, printer)
|
||||||
|
|
||||||
if err := build(programPath); err != nil {
|
if err = build(programPath); err != nil {
|
||||||
printer.Dangerf(err.Error())
|
printer.Dangerf(err.Error())
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user