Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support gogc config fix #61 #62

Open
wants to merge 7 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 6 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,9 @@ build_tags: ""
# Whether to prohibit automatic operation
disable_run: false

# use GOGC on build
build_go_gc: false

# log level, support debug, info, warn, error, fatal
log_level: "debug"
```
Expand Down
6 changes: 6 additions & 0 deletions README_ZH_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,12 @@ build_tags: ""
# 是否禁止自动运行
disable_run: false

# 编译时使用GOGC,false强制不使用,true根据环境变量配置来,默认使用
build_go_gc: false

# 日志级别, 支持 debug, info, warn, error, fatal
log_level: "debug"

```

## 微信公众号
Expand Down
2 changes: 2 additions & 0 deletions config.go
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package main

Check failure on line 1 in config.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.19)

: # github.com/silenceper/gowatch

Check failure on line 1 in config.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.20)

: # github.com/silenceper/gowatch

import (
"io/ioutil"
Expand All @@ -25,6 +25,8 @@
CmdArgs []string `yaml:"cmd_args"`
// Additional parameters during build
BuildArgs []string `yaml:"build_args"`
// use GOGC on build
BuildGOGC bool `yaml:"build_go_gc"`
// Environment variables added when running the application
Envs []string `yaml:"envs"`
// Specify whether the files in the vendor directory are also watched
Expand Down
8 changes: 6 additions & 2 deletions gowatch.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
"time"

"github.com/fsnotify/fsnotify"
"github.com/mitchellh/go-ps"
flyhope marked this conversation as resolved.
Show resolved Hide resolved
"github.com/silenceper/log"
)

Expand Down Expand Up @@ -152,7 +151,12 @@
args = append(args, files...)

bcmd := exec.Command(cmdName, args...)
bcmd.Env = append(os.Environ(), "GOGC=off")
bcmd.Env = os.Environ()
if !cfg.BuildGOGC {
bcmd.Env = append(bcmd.Env, "GOGC=off")
} else {
bcmd.Env = append(bcmd.Env, "GOGC=on")
}
silenceper marked this conversation as resolved.
Show resolved Hide resolved
bcmd.Stdout = os.Stdout
bcmd.Stderr = os.Stderr
log.Infof("Build Args: %s %s", cmdName, strings.Join(args, " "))
Expand Down Expand Up @@ -243,7 +247,7 @@
// implement pstree based on the cross-platform ps utility in go, go-ps
func psTree(rootPid int) (res []int, err error) {
pidOfInterest := map[int]struct{}{rootPid: {}}
pss, err := ps.Processes()

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / Test (1.16)

undefined: ps

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.16)

undefined: ps (typecheck)

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / Test (1.17)

undefined: ps

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.17)

undefined: ps (typecheck)

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / Test (1.18)

undefined: ps

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.18)

undefined: ps (typecheck)

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / Test (1.19)

undefined: ps

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.19)

undefined: ps (typecheck)

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / Test (1.20)

undefined: ps

Check failure on line 250 in gowatch.go

View workflow job for this annotation

GitHub Actions / golangci-lint (1.20)

undefined: ps (typecheck)
if err != nil {
fmt.Println("ERROR: ", err)
return
Expand All @@ -260,7 +264,7 @@

for _, ps := range pss {
ppid := ps.PPid()
if _, exists := pidOfInterest[ppid]; exists {

Check failure on line 267 in gowatch.go

View workflow job for this annotation

GitHub Actions / Test (1.17)

assignment mismatch: 2 variables but 1 value
pidOfInterest[ps.Pid()] = struct{}{}
}
}
Expand Down
3 changes: 3 additions & 0 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,9 @@ build_tags: ""
# Whether to prohibit automatic operation
disable_run: false

# use GOGC on build
build_go_gc: false

# log level, support debug, info, warn, error, fatal
log_level: "debug"
`
Expand Down
Loading