@@ -31,7 +31,10 @@ type Process struct {
31
31
func (p * Process ) IsWorker () bool { return strings .HasPrefix (p .Cmd , "nginx: worker" ) }
32
32
33
33
// 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
+ }
35
38
36
39
// IsShuttingDown returns true if the process is shutting down. This can identify workers that are in the process of a
37
40
// graceful shutdown. See [changing NGINX configuration] for more details.
@@ -53,6 +56,7 @@ type Option interface{ apply(opts *options) }
53
56
54
57
type optionFunc func (* options )
55
58
59
+ //nolint:ireturn
56
60
func (f optionFunc ) apply (o * options ) { f (o ) }
57
61
58
62
// 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
66
70
}
67
71
68
72
name , _ := p .NameWithContext (ctx ) // slow: shells out to ps
69
- if name != "nginx" {
73
+ if name != "nginx" && name != "nginx-debug" {
70
74
return nil , errNotAnNginxProcess
71
75
}
72
76
73
77
cmdLine , _ := p .CmdlineWithContext (ctx ) // slow: shells out to ps
74
78
// 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" ) {
76
81
return nil , errNotAnNginxProcess
77
82
}
78
83
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
+ }
84
90
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 ()
89
108
}
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
102
111
}
103
112
104
113
// List returns a slice of all NGINX processes. Returns a zero-length slice if no NGINX processes are found.
0 commit comments