mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Added ability to readback output from command line
Updated readme
This commit is contained in:
28
README.md
28
README.md
@@ -21,3 +21,31 @@ Create a new application
|
||||
```commandline
|
||||
revel new my/app
|
||||
```
|
||||
|
||||
## Community
|
||||
|
||||
* [Gitter](https://gitter.im/revel/community)
|
||||
* [StackOverflow](http://stackoverflow.com/questions/tagged/revel)
|
||||
|
||||
|
||||
## Learn More
|
||||
|
||||
* [Manual, Samples, Godocs, etc](http://revel.github.io)
|
||||
* [Apps using Revel](https://github.com/revel/revel/wiki/Apps-in-the-Wild)
|
||||
* [Articles Featuring Revel](https://github.com/revel/revel/wiki/Articles)
|
||||
|
||||
## Contributing
|
||||
|
||||
* [Contributing Code Guidelines](https://github.com/revel/revel/blob/master/CONTRIBUTING.md)
|
||||
* [Revel Contributors](https://github.com/revel/revel/graphs/contributors)
|
||||
|
||||
## Contributors
|
||||
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/0)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/1)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/2)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/3)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/4)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/5)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/6)
|
||||
[](https://sourcerer.io/fame/notzippy/revel/cmd/links/7)
|
||||
|
||||
@@ -60,7 +60,7 @@ func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelConta
|
||||
|
||||
// Start the app server, and wait until it is ready to serve requests.
|
||||
func (cmd AppCmd) Start(c *model.CommandConfig) error {
|
||||
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c}
|
||||
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}}
|
||||
cmd.Stdout = listeningWriter
|
||||
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env)
|
||||
utils.CmdInit(cmd.Cmd, c.AppPath)
|
||||
@@ -70,8 +70,11 @@ func (cmd AppCmd) Start(c *model.CommandConfig) error {
|
||||
|
||||
select {
|
||||
case exitState := <-cmd.waitChan():
|
||||
println("Revel proxy is listening, point your browser to :", c.Run.Port)
|
||||
return errors.New("revel/harness: app died reason: " + exitState)
|
||||
fmt.Println("Startup failure view previous messages, \n Proxy is listening :", c.Run.Port)
|
||||
err := utils.NewError("","Revel Run Error", "starting your application there was an exception. See terminal output, " + exitState,"")
|
||||
// TODO pretiffy command line output
|
||||
// err.MetaError = listeningWriter.getLastOutput()
|
||||
return err
|
||||
|
||||
case <-time.After(60 * time.Second):
|
||||
println("Revel proxy is listening, point your browser to :", c.Run.Port)
|
||||
@@ -160,8 +163,10 @@ type startupListeningWriter struct {
|
||||
dest io.Writer
|
||||
notifyReady chan bool
|
||||
c *model.CommandConfig
|
||||
buffer *bytes.Buffer
|
||||
}
|
||||
|
||||
// Writes to this output stream
|
||||
func (w *startupListeningWriter) Write(p []byte) (int, error) {
|
||||
if w.notifyReady != nil && bytes.Contains(p, []byte("Revel engine is listening on")) {
|
||||
w.notifyReady <- true
|
||||
@@ -173,5 +178,15 @@ func (w *startupListeningWriter) Write(p []byte) (int, error) {
|
||||
w.notifyReady = nil
|
||||
}
|
||||
}
|
||||
if w.notifyReady!=nil {
|
||||
w.buffer.Write(p)
|
||||
}
|
||||
return w.dest.Write(p)
|
||||
}
|
||||
|
||||
// Returns the cleaned output from the response
|
||||
// TODO clean the response more
|
||||
func (w *startupListeningWriter) getLastOutput() string {
|
||||
return w.buffer.String()
|
||||
}
|
||||
|
||||
|
||||
@@ -231,6 +231,9 @@ func (h *Harness) Refresh() (err *utils.Error) {
|
||||
h.app.Port = h.port
|
||||
if err2 := h.app.Cmd(h.runMode).Start(h.config); err2 != nil {
|
||||
utils.Logger.Error("Could not start application", "error", err2)
|
||||
if err,k :=err2.(*utils.Error);k {
|
||||
return err
|
||||
}
|
||||
return &utils.Error{
|
||||
Title: "App failed to start up",
|
||||
Description: err2.Error(),
|
||||
|
||||
@@ -23,6 +23,15 @@ type (
|
||||
IsError bool
|
||||
}
|
||||
)
|
||||
// Return a new error object
|
||||
func NewError(source, title,path,description string) *Error {
|
||||
return &Error {
|
||||
SourceType:source,
|
||||
Title:title,
|
||||
Path:path,
|
||||
Description:description,
|
||||
}
|
||||
}
|
||||
|
||||
// Creates a link based on the configuration setting "errors.link"
|
||||
func (e *Error) SetLink(errorLink string) {
|
||||
|
||||
Reference in New Issue
Block a user