From 5d99b7ae0f07a3d4bcd22f2f922d5856743a61d5 Mon Sep 17 00:00:00 2001 From: Yasuhiro Matsumoto Date: Wed, 30 Sep 2015 17:53:26 +0900 Subject: [PATCH] support windows --- runner/limit_unix.go | 17 +++++++++++++++++ runner/limit_windows.go | 6 ++++++ runner/logger.go | 5 +++-- runner/settings.go | 7 ++++++- runner/start.go | 11 ----------- 5 files changed, 32 insertions(+), 14 deletions(-) create mode 100644 runner/limit_unix.go create mode 100644 runner/limit_windows.go diff --git a/runner/limit_unix.go b/runner/limit_unix.go new file mode 100644 index 0000000..5972a21 --- /dev/null +++ b/runner/limit_unix.go @@ -0,0 +1,17 @@ +// +build !windows + +package runner + +import ( + "syscall" +) + +func initLimit() { + var rLimit syscall.Rlimit + rLimit.Max = 10000 + rLimit.Cur = 10000 + err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) + if err != nil { + fmt.Println("Error Setting Rlimit ", err) + } +} diff --git a/runner/limit_windows.go b/runner/limit_windows.go new file mode 100644 index 0000000..882519c --- /dev/null +++ b/runner/limit_windows.go @@ -0,0 +1,6 @@ +// +build windows + +package runner + +func initLimit() { +} diff --git a/runner/logger.go b/runner/logger.go index 4ccc0c3..ae2f3b1 100644 --- a/runner/logger.go +++ b/runner/logger.go @@ -3,13 +3,14 @@ package runner import ( "fmt" logPkg "log" - "os" "time" + + "github.com/mattn/go-colorable" ) type logFunc func(string, ...interface{}) -var logger = logPkg.New(os.Stderr, "", 0) +var logger = logPkg.New(colorable.NewColorableStderr(), "", 0) func newLogFunc(prefix string) func(string, ...interface{}) { color, clear := "", "" diff --git a/runner/settings.go b/runner/settings.go index 61e2412..725fbad 100644 --- a/runner/settings.go +++ b/runner/settings.go @@ -5,6 +5,7 @@ import ( "github.com/pilu/config" "os" "path/filepath" + "runtime" "strconv" "strings" "time" @@ -116,7 +117,11 @@ func buildName() string { return settings["build_name"] } func buildPath() string { - return filepath.Join(tmpPath(), buildName()) + p := filepath.Join(tmpPath(), buildName()) + if runtime.GOOS == "windows" && filepath.Ext(p) != ".exe" { + p += ".exe" + } + return p } func buildErrorsFileName() string { diff --git a/runner/start.go b/runner/start.go index b382dc3..82b8561 100644 --- a/runner/start.go +++ b/runner/start.go @@ -5,7 +5,6 @@ import ( "os" "runtime" "strings" - "syscall" "time" ) @@ -88,16 +87,6 @@ func initLogFuncs() { appLog = newLogFunc("app") } -func initLimit() { - var rLimit syscall.Rlimit - rLimit.Max = 10000 - rLimit.Cur = 10000 - err := syscall.Setrlimit(syscall.RLIMIT_NOFILE, &rLimit) - if err != nil { - fmt.Println("Error Setting Rlimit ", err) - } -} - func setEnvVars() { os.Setenv("DEV_RUNNER", "1") wd, err := os.Getwd()