Skip to content

Commit

Permalink
fix #9 (#16)
Browse files Browse the repository at this point in the history
  • Loading branch information
homiermorphism committed Jul 23, 2020
1 parent 0bae842 commit 2632d09
Showing 1 changed file with 17 additions and 1 deletion.
18 changes: 17 additions & 1 deletion cmd/root.go
Original file line number Diff line number Diff line change
Expand Up @@ -234,7 +234,23 @@ func run(cmd *cobra.Command, args []string) {
})
}

go srvr.Serve()
// Check to see if the port is already running, exit if so
shouldExitChan := make(chan bool)
go func() {
err := srvr.Serve()
if err != nil {
log.Println(err)
returnCode = 1
shouldExitChan <- true
} else {
shouldExitChan <- false
}
}()

if shouldExit := <- shouldExitChan; shouldExit {
return
}

<-srvr.Done
srvr.Shutdown(cmd.Context())
}

0 comments on commit 2632d09

Please sign in to comment.