@@ -31,7 +31,10 @@ type Process struct {
3131func (p * Process ) IsWorker () bool { return strings .HasPrefix (p .Cmd , "nginx: worker" ) }
3232
3333// IsMaster returns true if the process is a NGINX master process.
34- func (p * Process ) IsMaster () bool { return strings .HasPrefix (p .Cmd , "nginx: master" ) }
34+ func (p * Process ) IsMaster () bool {
35+ return strings .HasPrefix (p .Cmd , "nginx: master" ) ||
36+ strings .HasPrefix (p .Cmd , "{nginx-debug} nginx: master" )
37+ }
3538
3639// IsShuttingDown returns true if the process is shutting down. This can identify workers that are in the process of a
3740// graceful shutdown. See [changing NGINX configuration] for more details.
@@ -53,6 +56,7 @@ type Option interface{ apply(opts *options) }
5356
5457type optionFunc func (* options )
5558
59+ //nolint:ireturn
5660func (f optionFunc ) apply (o * options ) { f (o ) }
5761
5862// WithStatus runs an additional lookup to load the process status.
@@ -66,39 +70,44 @@ func convert(ctx context.Context, p *process.Process, o options) (*Process, erro
6670 }
6771
6872 name , _ := p .NameWithContext (ctx ) // slow: shells out to ps
69- if name != "nginx" {
73+ if name != "nginx" && name != "nginx-debug" {
7074 return nil , errNotAnNginxProcess
7175 }
7276
7377 cmdLine , _ := p .CmdlineWithContext (ctx ) // slow: shells out to ps
7478 // ignore nginx processes in the middle of an upgrade
75- if ! strings .HasPrefix (cmdLine , "nginx:" ) || strings .Contains (cmdLine , "upgrade" ) {
79+
80+ if strings .Contains (cmdLine , "upgrade" ) {
7681 return nil , errNotAnNginxProcess
7782 }
7883
79- var status string
80- if o .loadStatus {
81- flags , _ := p .StatusWithContext (ctx ) // slow: shells out to ps
82- status = strings .Join (flags , " " )
83- }
84+ if strings .HasPrefix (cmdLine , "nginx:" ) || strings .HasPrefix (cmdLine , "{nginx-debug} nginx:" ) {
85+ var status string
86+ if o .loadStatus {
87+ flags , _ := p .StatusWithContext (ctx ) // slow: shells out to ps
88+ status = strings .Join (flags , " " )
89+ }
8490
85- // unconditionally run fast lookups
86- var created time.Time
87- if millisSinceEpoch , err := p .CreateTimeWithContext (ctx ); err == nil {
88- created = time .UnixMilli (millisSinceEpoch )
91+ // unconditionally run fast lookups
92+ var created time.Time
93+ if millisSinceEpoch , err := p .CreateTimeWithContext (ctx ); err == nil {
94+ created = time .UnixMilli (millisSinceEpoch )
95+ }
96+ ppid , _ := p .PpidWithContext (ctx )
97+ exe , _ := p .ExeWithContext (ctx )
98+
99+ return & Process {
100+ PID : p .Pid ,
101+ PPID : ppid ,
102+ Name : name ,
103+ Cmd : cmdLine ,
104+ Created : created ,
105+ Status : status ,
106+ Exe : exe ,
107+ }, ctx .Err ()
89108 }
90- ppid , _ := p .PpidWithContext (ctx )
91- exe , _ := p .ExeWithContext (ctx )
92-
93- return & Process {
94- PID : p .Pid ,
95- PPID : ppid ,
96- Name : name ,
97- Cmd : cmdLine ,
98- Created : created ,
99- Status : status ,
100- Exe : exe ,
101- }, ctx .Err ()
109+
110+ return nil , errNotAnNginxProcess
102111}
103112
104113// List returns a slice of all NGINX processes. Returns a zero-length slice if no NGINX processes are found.
0 commit comments