mirror of
https://github.com/kevin-DL/revel-cmd.git
synced 2026-01-11 18:54:31 +00:00
Merge pull request #210 from revel/build_process_update
Updated Launch code
This commit is contained in:
@@ -12,6 +12,7 @@ import (
|
||||
"os"
|
||||
"os/exec"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
"time"
|
||||
|
||||
"github.com/revel/cmd/model"
|
||||
@@ -64,6 +65,7 @@ func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelConta
|
||||
func (cmd AppCmd) Start(c *model.CommandConfig) error {
|
||||
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}}
|
||||
cmd.Stdout = listeningWriter
|
||||
cmd.Stderr = listeningWriter
|
||||
utils.CmdInit(cmd.Cmd, !c.Vendored, c.AppPath)
|
||||
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env)
|
||||
if err := cmd.Cmd.Start(); err != nil {
|
||||
@@ -74,8 +76,9 @@ func (cmd AppCmd) Start(c *model.CommandConfig) error {
|
||||
case exitState := <-cmd.waitChan():
|
||||
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, "")
|
||||
atomic.SwapInt32(&startupError, 1)
|
||||
// TODO pretiffy command line output
|
||||
// err.MetaError = listeningWriter.getLastOutput()
|
||||
err.Stack = listeningWriter.buffer.String()
|
||||
return err
|
||||
|
||||
case <-time.After(60 * time.Second):
|
||||
|
||||
@@ -26,6 +26,7 @@ import (
|
||||
|
||||
var importErrorPattern = regexp.MustCompile("cannot find package \"([^\"]+)\"")
|
||||
var importErrorPattern2 = regexp.MustCompile("no required module provides package ([^;]+)+")
|
||||
var addPackagePattern = regexp.MustCompile(`to add:\n\tgo get (.*)\n`)
|
||||
|
||||
type ByString []*model.TypeInfo
|
||||
|
||||
@@ -214,6 +215,10 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
|
||||
if matches == nil {
|
||||
matches = importErrorPattern2.FindAllStringSubmatch(stOutput, -1)
|
||||
}
|
||||
if matches == nil {
|
||||
matches = addPackagePattern.FindAllStringSubmatch(stOutput, -1)
|
||||
|
||||
}
|
||||
utils.Logger.Info("Build failed checking for missing imports", "message", stOutput, "missing_imports", len(matches))
|
||||
if matches == nil {
|
||||
utils.Logger.Info("Build failed no missing imports", "message", stOutput)
|
||||
|
||||
@@ -42,6 +42,8 @@ var (
|
||||
doNotWatch = []string{"tmp", "views", "routes"}
|
||||
|
||||
lastRequestHadError int32
|
||||
startupError int32
|
||||
startupErrorText error
|
||||
)
|
||||
|
||||
// Harness reverse proxies requests to the application server.
|
||||
@@ -241,7 +243,7 @@ func (h *Harness) refresh() (err *utils.SourceError) {
|
||||
}
|
||||
err = &utils.SourceError{
|
||||
Title: "App failed to start up",
|
||||
Description: err.Error(),
|
||||
Description: newErr.Error(),
|
||||
}
|
||||
return
|
||||
}
|
||||
@@ -255,7 +257,7 @@ func (h *Harness) refresh() (err *utils.SourceError) {
|
||||
if len(h.app.PackagePathMap) > 0 {
|
||||
paths, _ = json.Marshal(h.app.PackagePathMap)
|
||||
}
|
||||
runMode = fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, h.app.Paths.RunMode, h.config.Verbose, string(paths))
|
||||
runMode = fmt.Sprintf(`{"mode":"%s", "specialUseFlag":%v,"packagePathMap":%s}`, h.app.Paths.RunMode, h.config.Verbose[0], string(paths))
|
||||
}
|
||||
if err2 := h.app.Cmd(runMode).Start(h.config); err2 != nil {
|
||||
utils.Logger.Error("Could not start application", "error", err2)
|
||||
@@ -297,6 +299,7 @@ func (h *Harness) Run() {
|
||||
paths = append(paths, h.paths.CodePaths...)
|
||||
h.watcher = watcher.NewWatcher(h.paths, false)
|
||||
h.watcher.Listen(h, paths...)
|
||||
|
||||
go h.Refresh()
|
||||
// h.watcher.Notify()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user