Skip to content

Commit c27216c

Browse files
Akshay2191aphralG
andauthored
Fix nginx-debug binary not found (#1498)
* fix nginx-debug binary not found --------- Co-authored-by: Aphral Griffin <a.griffin@f5.com>
1 parent 62ab46e commit c27216c

File tree

4 files changed

+24
-3
lines changed

4 files changed

+24
-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 name == "nginx" && !strings.Contains(cmd, "upgrade") && strings.HasPrefix(cmd, "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: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,18 @@ 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+
},
1154+
{
1155+
name: "nginx-debug process",
1156+
pName: "nginx-debug",
1157+
cmd: "{nginx-debug} nginx: master process /usr/sbin/nginx-debug -g daemon off;",
1158+
expect: true,
1159+
},
11481160
}
11491161

11501162
for _, tt := range tests {

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)