Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
7 changes: 6 additions & 1 deletion src/core/environment.go
Original file line number Diff line number Diff line change
Expand Up @@ -656,7 +656,12 @@ func (env *EnvironmentType) Processes() (result []*Process) {
}

func (env *EnvironmentType) isNginxProcess(name string, cmd string) bool {
return name == "nginx" && !strings.Contains(cmd, "upgrade") && strings.HasPrefix(cmd, "nginx:")
base := filepath.Base(name) // strip path if any

// Accept both the normal nginx binary and the debug binary
isNginxBinary := base == "nginx" || base == "nginx-debug"

return isNginxBinary && !strings.Contains(cmd, "upgrade") && strings.HasPrefix(cmd, "nginx:")
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

when in NGINX is in debug I think the cmd would start with {nginx-debug} nginx:

}

func getNginxProcessExe(nginxProcess *process.Process) string {
Expand Down
24 changes: 24 additions & 0 deletions src/core/environment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1145,6 +1145,30 @@ func TestGetNginxProcess(t *testing.T) {
cmd: "nginx: upgrade",
expect: false,
},
{
name: "nginx binary with master cmd",
pName: "nginx",
cmd: "nginx: master process /usr/sbin/nginx -c /etc/nginx/nginx.conf",
expect: true,
},
{
name: "nginx-debug binary with master cmd",
pName: "nginx-debug",
cmd: "nginx: master process /usr/sbin/nginx-debug -c /etc/nginx/nginx.conf",
expect: true,
},
{
name: "nginx-asg-sync shouldn't match",
pName: "nginx-asg-sync",
cmd: "/usr/sbin/nginx-asg-sync -log_path=/var/log/...",
expect: false,
},
{
name: "nginx upgrade excluded",
pName: "nginx",
cmd: "nginx: upgrade",
expect: false,
},
}

for _, tt := range tests {
Expand Down
Loading