Skip to content

Commit d0bbd7d

Browse files
committed
fix nginx-debug binary not found
1 parent 2a390ac commit d0bbd7d

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
lines changed

src/core/environment.go

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,12 @@ func (env *EnvironmentType) Processes() (result []*Process) {
656656
}
657657

658658
func (env *EnvironmentType) isNginxProcess(name string, cmd string) bool {
659-
return name == "nginx" && !strings.Contains(cmd, "upgrade") && strings.HasPrefix(cmd, "nginx:")
659+
base := filepath.Base(name) // strip path if any
660+
661+
// Accept both the normal nginx binary and the debug binary
662+
isNginxBinary := base == "nginx" || base == "nginx-debug"
663+
664+
return isNginxBinary && !strings.Contains(cmd, "upgrade") && strings.HasPrefix(cmd, "nginx:")
660665
}
661666

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

src/core/environment_test.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,30 @@ func TestGetNginxProcess(t *testing.T) {
11451145
cmd: "nginx: upgrade",
11461146
expect: false,
11471147
},
1148+
{
1149+
name: "nginx binary with master cmd",
1150+
pName: "nginx",
1151+
cmd: "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf",
1152+
expect: true,
1153+
},
1154+
{
1155+
name: "nginx-debug binary with master cmd",
1156+
pName: "nginx-debug",
1157+
cmd: "nginx: master process /usr/sbin/nginx-debug -c /etc/nginx/nginx.conf",
1158+
expect: true,
1159+
},
1160+
{
1161+
name: "nginx-asg-sync shouldn't match",
1162+
pName: "nginx-asg-sync",
1163+
cmd: "/usr/sbin/nginx-asg-sync -log_path=/var/log/...",
1164+
expect: false,
1165+
},
1166+
{
1167+
name: "nginx upgrade excluded",
1168+
pName: "nginx",
1169+
cmd: "nginx: upgrade",
1170+
expect: false,
1171+
},
11481172
}
11491173

11501174
for _, tt := range tests {

0 commit comments

Comments
 (0)