server startup fixed
This commit is contained in:
parent
e7fd7ce26f
commit
6a53bd9c80
|
@ -115,6 +115,7 @@ func main() {
|
|||
&cli.BoolFlag{Name: "build", Aliases: []string{"b"}, Value: false, Usage: "Enable go build."},
|
||||
&cli.BoolFlag{Name: "legacy", Aliases: []string{"l"}, Value: false, Usage: "Watch by polling instead of Watch by fsnotify."},
|
||||
&cli.BoolFlag{Name: "server", Aliases: []string{"s"}, Value: false, Usage: "Enable server and open into the default browser."},
|
||||
&cli.BoolFlag{Name: "open", Aliases: []string{"o"}, Value: false, Usage: "Open server directly in the default browser."},
|
||||
&cli.BoolFlag{Name: "no-run", Aliases: []string{"nr"}, Value: false, Usage: "Disable go run"},
|
||||
&cli.BoolFlag{Name: "no-install", Aliases: []string{"ni"}, Value: false, Usage: "Disable go install"},
|
||||
&cli.BoolFlag{Name: "no-config", Aliases: []string{"nc"}, Value: false, Usage: "Ignore existing configurations."},
|
||||
|
|
|
@ -52,7 +52,14 @@ func render(c echo.Context, path string, mime int) error {
|
|||
|
||||
// Start the web server
|
||||
func (s *Server) Start(p *cli.Context) (err error) {
|
||||
if s.Server.Status || p.Bool("server") {
|
||||
if p.Bool("server"){
|
||||
s.Server.Status = p.Bool("server")
|
||||
}
|
||||
if p.Bool("open") {
|
||||
s.Server.Open = p.Bool("open")
|
||||
}
|
||||
|
||||
if s.Server.Status {
|
||||
e := echo.New()
|
||||
e.Use(middleware.GzipWithConfig(middleware.GzipConfig{
|
||||
Level: 2,
|
||||
|
@ -110,7 +117,7 @@ func (s *Server) Start(p *cli.Context) (err error) {
|
|||
e.GET("/ws", s.projects)
|
||||
|
||||
go e.Start(string(s.Settings.Server.Host) + ":" + strconv.Itoa(s.Settings.Server.Port))
|
||||
if s.Open || p.Bool("open") {
|
||||
if s.Open {
|
||||
_, err = Open("http://" + string(s.Settings.Server.Host) + ":" + strconv.Itoa(s.Settings.Server.Port))
|
||||
if err != nil {
|
||||
return err
|
||||
|
|
Loading…
Reference in New Issue