Skip to content

Commit 49eef29

Browse files
author
notzippy@gmail.com
committed
Build and Historic build updates
Modified GOPATH to not modify build with go.mod Updated go.mod to version 1.12 Updated harness to setup listener before killing process Updated notvendored flag to --no-vendor Updated command_config to ensure no-vendor can be build Added additional checks in source path lookup
1 parent 9d3a554 commit 49eef29

File tree

10 files changed

+124
-154
lines changed

10 files changed

+124
-154
lines changed

.travis.yml

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,10 +28,11 @@ install:
2828
- 'if [[ "$TRAVIS_BRANCH" == "master" ]]; then export REVEL_BRANCH="master"; fi'
2929
- 'echo "Travis branch: $TRAVIS_BRANCH, Revel dependency branch: $REVEL_BRANCH"'
3030
# Since travis already checks out go build the commandline tool (revel)
31-
- go get -v github.com/revel/cmd/revel
32-
- echo $GOPATH
33-
- echo $PATH
31+
- mkdir $HOME/GOPATH_PROTECTED
32+
- export GOPATH=$HOME/GOPATH_PROTECTED
33+
- go build -o $HOME/gopath/bin/revel github.com/revel/cmd/revel
3434
- pwd
35+
- env
3536
script:
3637
- go test -v github.com/revel/cmd/revel/...
3738

@@ -54,6 +55,12 @@ script:
5455
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v
5556
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v -m prod
5657

58+
# Check build works with no-vendor flag
59+
- cd $GOPATH
60+
- export GO111MODULE=auto
61+
- revel new -a my/testapp2 --no-vendor
62+
- revel test -a my/testapp2
63+
5764
matrix:
5865
allow_failures:
5966
- go: tip

go.mod

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
module github.com/revel/cmd
22

3-
go 1.13
3+
go 1.12
44

55
require (
66
github.com/BurntSushi/toml v0.3.1 // indirect
77
github.com/agtorre/gocolorize v1.0.0
88
github.com/fsnotify/fsnotify v1.4.7
99
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect
1010
github.com/jessevdk/go-flags v1.4.0
11-
github.com/mattn/go-colorable v0.1.4
11+
github.com/mattn/go-colorable v0.1.6
1212
github.com/myesui/uuid v1.0.0 // indirect
1313
github.com/pkg/errors v0.9.1
1414
github.com/revel/config v0.21.0
@@ -19,7 +19,8 @@ require (
1919
github.com/stretchr/testify v1.4.0
2020
github.com/twinj/uuid v1.0.0 // indirect
2121
github.com/xeonx/timeago v1.0.0-rc4 // indirect
22-
golang.org/x/net v0.0.0-20200202094626-16171245cfb2 // indirect
22+
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect
23+
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect
2324
golang.org/x/tools v0.0.0-20200219054238-753a1d49df85
2425
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
2526
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22

harness/app.go

Lines changed: 23 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@ import (
1212
"os"
1313
"os/exec"
1414
"time"
15+
"sync"
1516

1617
"github.com/revel/cmd/model"
1718
"github.com/revel/cmd/utils"
@@ -64,8 +65,8 @@ func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelConta
6465
func (cmd AppCmd) Start(c *model.CommandConfig) error {
6566
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}}
6667
cmd.Stdout = listeningWriter
67-
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env)
6868
utils.CmdInit(cmd.Cmd, !c.Vendored, c.AppPath)
69+
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env)
6970
if err := cmd.Cmd.Start(); err != nil {
7071
utils.Logger.Fatal("Error running:", "error", err)
7172
}
@@ -107,10 +108,30 @@ func (cmd AppCmd) Kill() {
107108
// server before this can, this check will ensure the process is still running
108109
if _, err := os.FindProcess(int(cmd.Process.Pid));err!=nil {
109110
// Server has already exited
110-
utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
111+
utils.Logger.Info("Server not running revel server pid", "pid", cmd.Process.Pid)
111112
return
112113
}
113114

115+
// Wait for the shutdown channel
116+
waitMutex := &sync.WaitGroup{}
117+
waitMutex.Add(1)
118+
ch := make(chan bool, 1)
119+
go func() {
120+
waitMutex.Done()
121+
s, err := cmd.Process.Wait()
122+
defer func() {
123+
ch <- true
124+
}()
125+
if err != nil {
126+
utils.Logger.Info("Wait failed for process ", "error", err)
127+
}
128+
if s != nil {
129+
utils.Logger.Info("Revel App exited", "state", s.String())
130+
}
131+
}()
132+
// Wait for the channel to begin waiting
133+
waitMutex.Wait()
134+
114135
// Send an interrupt signal to allow for a graceful shutdown
115136
utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
116137
var err error
@@ -129,20 +150,6 @@ func (cmd AppCmd) Kill() {
129150
return
130151
}
131152

132-
// Wait for the shutdown
133-
ch := make(chan bool, 1)
134-
go func() {
135-
s, err := cmd.Process.Wait()
136-
defer func() {
137-
ch <- true
138-
}()
139-
if err != nil {
140-
utils.Logger.Info("Wait failed for process ", "error", err)
141-
}
142-
if s != nil {
143-
utils.Logger.Info("Revel App exited", "state", s.String())
144-
}
145-
}()
146153

147154
// Use a timer to ensure that the process exits
148155
utils.Logger.Info("Waiting to exit")

harness/build.go

Lines changed: 2 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -102,28 +102,8 @@ func Build(c *model.CommandConfig, paths *model.RevelContainer) (_ *App, err err
102102
utils.Logger.Fatal("Go executable not found in PATH.")
103103
}
104104

105-
// Detect if deps tool should be used (is there a vendor folder ?)
106-
useVendor := utils.DirExists(filepath.Join(paths.BasePath, "vendor"))
107-
basePath := paths.BasePath
108-
for !useVendor {
109-
basePath = filepath.Dir(basePath)
110-
found := false
111-
// Check to see if we are still in the GOPATH
112-
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
113-
if strings.HasPrefix(basePath, gopath) {
114-
found = true
115-
break
116-
}
117-
}
118-
if !found {
119-
break
120-
} else {
121-
useVendor = utils.DirExists(filepath.Join(basePath, "vendor"))
122-
}
123-
}
124-
125-
// Binary path is a combination of BasePath/target/app directory, app's import path and its name.
126-
binName := filepath.Join(paths.BasePath, "target", "app", paths.ImportPath, filepath.Base(paths.BasePath))
105+
// Binary path is a combination of target/app directory, app's import path and its name.
106+
binName := filepath.Join("target", "app", paths.ImportPath, filepath.Base(paths.BasePath))
127107

128108
// Change binary path for Windows build
129109
goos := runtime.GOOS

model/command/new.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ type (
66
ImportCommand
77
SkeletonPath string `short:"s" long:"skeleton" description:"Path to skeleton folder (Must exist on GO PATH)" required:"false"`
88
Package string `short:"p" long:"package" description:"The package name, this becomes the repfix to the app name, if defined vendored is set to true" required:"false"`
9-
NotVendored bool `long:"not-vendor" description:"True if project should not be configured with a go.mod, this requires you to have the project on the GOPATH"`
9+
NotVendored bool `long:"no-vendor" description:"True if project should not be configured with a go.mod, this requires you to have the project on the GOPATH, this is only compatible with go versions v1.12 or older"`
1010
Run bool `short:"r" long:"run" description:"True if you want to run the application right away"`
1111
Callback func() error
1212
}

0 commit comments

Comments
 (0)