@@ -140,6 +140,7 @@ var initCmd = &cobra.Command{
140
140
select {
141
141
case <- supervisorDone :
142
142
// supervisor has ended - we're all done here
143
+ defer log .Info ("supervisor has ended (supervisorDone)" )
143
144
return
144
145
case <- sigInput :
145
146
ignoreUnexpectedExitCode .Store (true )
@@ -160,8 +161,10 @@ var initCmd = &cobra.Command{
160
161
select {
161
162
case <- ctx .Done ():
162
163
// Time is up, but we give all the goroutines a bit more time to react to this.
163
- time .Sleep (time .Millisecond * 500 )
164
+ time .Sleep (time .Millisecond * 1000 )
165
+ defer log .Info ("supervisor has ended (ctx.Done)" )
164
166
case <- terminationDone :
167
+ defer log .Info ("supervisor has ended (terminationDone)" )
165
168
}
166
169
slog .write ("Finished shutting down all processes." )
167
170
}
@@ -229,10 +232,12 @@ type shutdownLoggerImpl struct {
229
232
230
233
func (l * shutdownLoggerImpl ) write (s string ) {
231
234
if l .file != nil {
232
- _ , err := l .file .WriteString (fmt .Sprintf ("[%s] %s \n " , time .Since (l .startTime ), s ))
235
+ msg := fmt .Sprintf ("[%s] %s \n " , time .Since (l .startTime ), s )
236
+ _ , err := l .file .WriteString (msg )
233
237
if err != nil {
234
238
log .WithError (err ).Error ("couldn't write to log file" )
235
239
}
240
+ log .Infof ("slog: %s" , msg )
236
241
} else {
237
242
log .Debug (s )
238
243
}
@@ -250,6 +255,7 @@ func (l *shutdownLoggerImpl) TerminateSync(ctx context.Context, pid int) {
250
255
if err != nil {
251
256
l .write (fmt .Sprintf ("Couldn't obtain process information for PID %d." , pid ))
252
257
} else if stat .State == "Z" {
258
+ l .write (fmt .Sprintf ("Process %s with PID %d is a zombie, skipping termination." , stat .Comm , pid ))
253
259
return
254
260
} else {
255
261
l .write (fmt .Sprintf ("Terminating process %s with PID %d (state: %s, cmdlind: %s)." , stat .Comm , pid , stat .State , fmt .Sprint (proc .CmdLine ())))
0 commit comments