Skip to content

Commit

Permalink
Merge pull request #161 from notzippy/master
Browse files Browse the repository at this point in the history
Patch for windows
  • Loading branch information
notzippy authored Nov 2, 2018
2 parents 5f558ac + dfb08d9 commit 149f9f9
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 9 deletions.
24 changes: 22 additions & 2 deletions harness/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import (

"github.com/revel/cmd/model"
"github.com/revel/cmd/utils"
"runtime"
)

// App contains the configuration for running a Revel app. (Not for the app itself)
Expand Down Expand Up @@ -101,11 +102,30 @@ func (cmd AppCmd) Run() {
func (cmd AppCmd) Kill() {

if cmd.Cmd != nil && (cmd.ProcessState == nil || !cmd.ProcessState.Exited()) {
// Windows appears to send the kill to all threads, shutting down the
// server before this can, this check will ensure the process is still running
if _, err := os.FindProcess(int(cmd.Process.Pid));err!=nil {
// Server has already exited
utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
return
}

// Send an interrupt signal to allow for a graceful shutdown
utils.Logger.Info("Killing revel server pid", "pid", cmd.Process.Pid)
err := cmd.Process.Signal(os.Interrupt)
var err error
if runtime.GOOS == "windows" {
// os.Interrupt is not available on windows
err = cmd.Process.Signal(os.Kill)
} else {
err = cmd.Process.Signal(os.Interrupt)
}

if err != nil {
utils.Logger.Fatal("Failed to kill revel server:", "error", err)
utils.Logger.Error(
"Revel app failed to kill process.",
"processid", cmd.Process.Pid,"error",err,
"killerror", cmd.Process.Kill())
return
}

// Wait for the shutdown
Expand Down
2 changes: 1 addition & 1 deletion model/command_config.go
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ type (
// The version command
Version struct {
ImportPath string `short:"a" long:"application-path" description:"Path to application folder" required:"false"`
Update bool `short:"u" long:"Update the framework and modules" required:"false"`
Update bool `short:"u" long:"update" description:"Update the framework and modules" required:"false"`
} `command:"version"`
}
)
Expand Down
2 changes: 1 addition & 1 deletion parser/appends.go
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ func appendAction(fset *token.FileSet, mm methodMap, decl ast.Decl, pkgImportPat
var importPath string
typeExpr := model.NewTypeExprFromAst(pkgName, field.Type)
if !typeExpr.Valid {
utils.Logger.Warn("Warn: Didn't understand argument '%s' of action %s. Ignoring.", name, getFuncName(funcDecl))
utils.Logger.Warnf("Warn: Didn't understand argument '%s' of action %s. Ignoring.", name, getFuncName(funcDecl))
return // We didn't understand one of the args. Ignore this action.
}
// Local object
Expand Down
7 changes: 4 additions & 3 deletions parser/imports.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,10 @@ func addImports(imports map[string]string, decl ast.Decl, srcDir string) {

// Returns a valid import string from the path
// using the build.Defaul.GOPATH to determine the root
func importPathFromPath(root string) string {
if vendorIdx := strings.Index(root, "/vendor/"); vendorIdx != -1 {
return filepath.ToSlash(root[vendorIdx+8:])
func importPathFromPath(root, basePath string) string {
vendorTest := filepath.Join(basePath, "vendor")
if len(root) > len(vendorTest) && root[:len(vendorTest)] == vendorTest {
return filepath.ToSlash(root[len(vendorTest)+1:])
}
for _, gopath := range filepath.SplitList(build.Default.GOPATH) {
srcPath := filepath.Join(gopath, "src")
Expand Down
2 changes: 1 addition & 1 deletion parser/reflect.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ type methodMap map[string][]*model.MethodSpec
func ProcessSource(paths *model.RevelContainer) (_ *model.SourceInfo, compileError error) {
pc := &processContainer{paths: paths}
for _, root := range paths.CodePaths {
rootImportPath := importPathFromPath(root)
rootImportPath := importPathFromPath(root, paths.BasePath)
if rootImportPath == "" {
utils.Logger.Info("Skipping empty code path", "path", root)
continue
Expand Down
2 changes: 1 addition & 1 deletion version.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ package cmd

const (
// Version current Revel version
Version = "0.21.0"
Version = "0.21.1"

// BuildDate latest commit/release date
BuildDate = "2018-10-30"
Expand Down

0 comments on commit 149f9f9

Please sign in to comment.