Skip to content

Commit 60b88a4

Browse files
authored
Merge pull request #180 from notzippy/go-mod
Initial commit to go mod
2 parents d201463 + 49eef29 commit 60b88a4

40 files changed

+1456
-611
lines changed

.codebeatsettings

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
{
22
"GOLANG": {
3-
"ABC":[25, 35, 50, 70],
3+
"ABC":[33, 38, 50, 70],
44
"ARITY":[5,6,7,8],
5-
"BLOCK_NESTING":[7, 9, 11, 13],
6-
"CYCLO":[20, 30, 45, 60],
7-
"TOO_MANY_IVARS": [20, 25, 40, 45],
5+
"BLOCK_NESTING":[9, 10, 12, 13],
6+
"CYCLO":[30, 35, 45, 60],
7+
"TOO_MANY_IVARS": [28, 30, 40, 45],
88
"TOO_MANY_FUNCTIONS": [20, 30, 40, 50],
99
"TOTAL_COMPLEXITY": [150, 250, 400, 500],
1010
"LOC": [100, 175, 250, 320],
1111
"TOTAL_LOC": [300, 400, 500, 600]
1212
}
13-
}
13+
}

.travis.yml

Lines changed: 31 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,9 @@
11
language: go
22

33
go:
4-
- "1.8.x"
5-
- "1.9.x"
6-
- "1.10.x"
7-
- "1.11.x"
4+
- "1.12.x"
5+
- "1.13.x"
6+
- "1.14.x"
87
- "tip"
98

109
os:
@@ -19,49 +18,48 @@ branches:
1918
- master
2019
- develop
2120

21+
env:
22+
# Setting environments variables
23+
- GO111MODULE=on
2224

2325
install:
24-
# Setting environments variables
2526
- export PATH=$PATH:$HOME/gopath/bin
2627
- export REVEL_BRANCH="develop"
2728
- 'if [[ "$TRAVIS_BRANCH" == "master" ]]; then export REVEL_BRANCH="master"; fi'
2829
- 'echo "Travis branch: $TRAVIS_BRANCH, Revel dependency branch: $REVEL_BRANCH"'
29-
- git clone -b $REVEL_BRANCH git://github.com/revel/revel ../revel/
30-
- git clone -b $REVEL_BRANCH git://github.com/revel/modules ../modules/
31-
- go get -t -v github.com/revel/cmd/revel
32-
- go get -u github.com/golang/dep/cmd/dep
33-
- echo $GOPATH
34-
- echo $PATH
30+
# Since travis already checks out go build the commandline tool (revel)
31+
- mkdir $HOME/GOPATH_PROTECTED
32+
- export GOPATH=$HOME/GOPATH_PROTECTED
33+
- go build -o $HOME/gopath/bin/revel github.com/revel/cmd/revel
3534
- pwd
35+
- env
3636
script:
3737
- go test -v github.com/revel/cmd/revel/...
3838

3939
# Ensure the new-app flow works (plus the other commands).
40-
- revel version
41-
- revel new my/testapp
42-
- revel test my/testapp
43-
- revel clean my/testapp
44-
- revel build my/testapp build/testapp
45-
- revel build my/testapp build/testapp prod
46-
- revel package my/testapp
47-
- revel package my/testapp prod
40+
#- revel version
41+
#- revel new my/testapp
42+
#- revel test my/testapp
43+
#- revel clean my/testapp
44+
#- revel build my/testapp build/testapp
45+
#- revel build my/testapp build/testapp prod
46+
#- revel package my/testapp
47+
#- revel package my/testapp prod
4848

4949
# Ensure the new-app flow works (plus the other commands).
50-
- revel new -a my/testapp2
51-
- revel test -a my/testapp2
52-
- revel clean -a my/testapp2
53-
- revel build -a my/testapp2 -t build/testapp2
54-
- revel build -a my/testapp2 -t build/testapp2 -m prod
55-
- revel package -a my/testapp2
56-
- revel package -a my/testapp2 -m prod
50+
- revel new --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v
51+
- revel test --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v
52+
- revel clean --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v
53+
- revel build --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v -t build/testapp2
54+
- revel build --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v -t build/testapp2 -m prod
55+
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v
56+
- revel package --gomod-flags "edit -replace=github.com/revel/revel=github.com/revel/revel@develop" -a my/testapp2 -v -m prod
5757

58-
- revel new -v -a my/testapp3 -V
59-
- revel test -v -a my/testapp3
60-
- revel clean -v -a my/testapp3
61-
- revel build -a my/testapp3 -t build/testapp3
62-
- revel build -a my/testapp3 -t build/testapp3 -m prod
63-
- revel package -a my/testapp3
64-
- revel package -a my/testapp3 -m prod
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
6563

6664
matrix:
6765
allow_failures:

go.mod

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
module github.com/revel/cmd
2+
3+
go 1.12
4+
5+
require (
6+
github.com/BurntSushi/toml v0.3.1 // indirect
7+
github.com/agtorre/gocolorize v1.0.0
8+
github.com/fsnotify/fsnotify v1.4.7
9+
github.com/inconshreveable/log15 v0.0.0-20200109203555-b30bc20e4fd1 // indirect
10+
github.com/jessevdk/go-flags v1.4.0
11+
github.com/mattn/go-colorable v0.1.6
12+
github.com/myesui/uuid v1.0.0 // indirect
13+
github.com/pkg/errors v0.9.1
14+
github.com/revel/config v0.21.0
15+
github.com/revel/log15 v2.11.20+incompatible
16+
github.com/revel/modules v0.21.0 // indirect
17+
github.com/revel/pathtree v0.0.0-20140121041023-41257a1839e9 // indirect
18+
github.com/revel/revel v0.21.0
19+
github.com/stretchr/testify v1.4.0
20+
github.com/twinj/uuid v1.0.0 // indirect
21+
github.com/xeonx/timeago v1.0.0-rc4 // indirect
22+
golang.org/x/net v0.0.0-20200501053045-e0ff5e5a1de5 // indirect
23+
golang.org/x/sys v0.0.0-20200501145240-bc7a7d42d5c3 // indirect
24+
golang.org/x/tools v0.0.0-20200219054238-753a1d49df85
25+
gopkg.in/fsnotify/fsnotify.v1 v1.4.7
26+
gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22
27+
gopkg.in/natefinch/lumberjack.v2 v2.0.0
28+
gopkg.in/stack.v0 v0.0.0-20141108040640-9b43fcefddd0
29+
gopkg.in/stretchr/testify.v1 v1.2.2 // indirect
30+
)

harness/app.go

Lines changed: 35 additions & 27 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"
@@ -21,15 +22,16 @@ import (
2122
// App contains the configuration for running a Revel app. (Not for the app itself)
2223
// Its only purpose is constructing the command to execute.
2324
type App struct {
24-
BinaryPath string // Path to the app executable
25-
Port int // Port to pass as a command line argument.
26-
cmd AppCmd // The last cmd returned.
27-
Paths *model.RevelContainer
25+
BinaryPath string // Path to the app executable
26+
Port int // Port to pass as a command line argument.
27+
cmd AppCmd // The last cmd returned.
28+
PackagePathMap map[string]string // Package to directory path map
29+
Paths *model.RevelContainer
2830
}
2931

3032
// NewApp returns app instance with binary path in it
31-
func NewApp(binPath string, paths *model.RevelContainer) *App {
32-
return &App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort}
33+
func NewApp(binPath string, paths *model.RevelContainer, packagePathMap map[string]string) *App {
34+
return &App{BinaryPath: binPath, Paths: paths, Port: paths.HTTPPort, PackagePathMap:packagePathMap}
3335
}
3436

3537
// Cmd returns a command to run the app server using the current configuration.
@@ -63,18 +65,18 @@ func NewAppCmd(binPath string, port int, runMode string, paths *model.RevelConta
6365
func (cmd AppCmd) Start(c *model.CommandConfig) error {
6466
listeningWriter := &startupListeningWriter{os.Stdout, make(chan bool), c, &bytes.Buffer{}}
6567
cmd.Stdout = listeningWriter
68+
utils.CmdInit(cmd.Cmd, !c.Vendored, c.AppPath)
6669
utils.Logger.Info("Exec app:", "path", cmd.Path, "args", cmd.Args, "dir", cmd.Dir, "env", cmd.Env)
67-
utils.CmdInit(cmd.Cmd, c.AppPath)
6870
if err := cmd.Cmd.Start(); err != nil {
6971
utils.Logger.Fatal("Error running:", "error", err)
7072
}
7173

7274
select {
7375
case exitState := <-cmd.waitChan():
7476
fmt.Println("Startup failure view previous messages, \n Proxy is listening :", c.Run.Port)
75-
err := utils.NewError("","Revel Run Error", "starting your application there was an exception. See terminal output, " + exitState,"")
76-
// TODO pretiffy command line output
77-
// err.MetaError = listeningWriter.getLastOutput()
77+
err := utils.NewError("", "Revel Run Error", "starting your application there was an exception. See terminal output, " + exitState, "")
78+
// TODO pretiffy command line output
79+
// err.MetaError = listeningWriter.getLastOutput()
7880
return err
7981

8082
case <-time.After(60 * time.Second):
@@ -106,10 +108,30 @@ func (cmd AppCmd) Kill() {
106108
// server before this can, this check will ensure the process is still running
107109
if _, err := os.FindProcess(int(cmd.Process.Pid));err!=nil {
108110
// Server has already exited
109-
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)
110112
return
111113
}
112114

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+
113135
// Send an interrupt signal to allow for a graceful shutdown
114136
utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
115137
var err error
@@ -128,28 +150,14 @@ func (cmd AppCmd) Kill() {
128150
return
129151
}
130152

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

146154
// Use a timer to ensure that the process exits
147155
utils.Logger.Info("Waiting to exit")
148156
select {
149157
case <-ch:
150158
return
151159
case <-time.After(60 * time.Second):
152-
// Kill the process
160+
// Kill the process
153161
utils.Logger.Error(
154162
"Revel app failed to exit in 60 seconds - killing.",
155163
"processid", cmd.Process.Pid,
@@ -198,7 +206,7 @@ func (w *startupListeningWriter) Write(p []byte) (int, error) {
198206
w.notifyReady = nil
199207
}
200208
}
201-
if w.notifyReady!=nil {
209+
if w.notifyReady != nil {
202210
w.buffer.Write(p)
203211
}
204212
return w.dest.Write(p)

0 commit comments

Comments
 (0)