Skip to content

Commit 4664ea5

Browse files
committed
PR feedback
1 parent 2f560eb commit 4664ea5

File tree

4 files changed

+18
-3
lines changed

4 files changed

+18
-3
lines changed

src/core/environment.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -606,6 +606,7 @@ func (env *EnvironmentType) Processes() (result []*Process) {
606606
cmd, _ := p.CmdlineWithContext(ctx)
607607

608608
if env.isNginxProcess(name, cmd) {
609+
log.Infof("-------------------- %v", name)
609610
nginxProcesses[pid] = p
610611
}
611612

@@ -656,7 +657,9 @@ func (env *EnvironmentType) Processes() (result []*Process) {
656657
}
657658

658659
func (env *EnvironmentType) isNginxProcess(name string, cmd string) bool {
659-
return !strings.Contains(cmd, "upgrade") && (strings.HasPrefix(cmd, "nginx:") || strings.HasPrefix(cmd, "{nginx-debug} nginx:"))
660+
isNameValid := name == "nginx" || name == "nginx-debug"
661+
isCmdValid := strings.HasPrefix(cmd, "nginx:") || strings.HasPrefix(cmd, "{nginx-debug} nginx:")
662+
return !strings.Contains(cmd, "upgrade") && isNameValid && isCmdValid
660663
}
661664

662665
func getNginxProcessExe(nginxProcess *process.Process) string {

src/core/environment_test.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,12 @@ func TestGetNginxProcess(t *testing.T) {
11451145
cmd: "nginx: upgrade",
11461146
expect: false,
11471147
},
1148+
{
1149+
name: "nginx-debug process",
1150+
pName: "nginx-debug",
1151+
cmd: "nginx: master process /usr/sbin/nginx-debug -c /etc/nginx/nginx.conf",
1152+
expect: true,
1153+
},
11481154
{
11491155
name: "nginx-debug process",
11501156
pName: "nginx-debug",

test/integration/vendor/github.com/nginx/agent/v2/src/core/environment.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

test/performance/vendor/github.com/nginx/agent/v2/src/core/environment.go

Lines changed: 4 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)