@@ -179,8 +179,10 @@ func (r *Runner) Run() error {
179
179
reexec .NotifyForeground ("started" )
180
180
}
181
181
182
+ terminal .Logger .Debug ().Msg ("Waiting for channels (first boot)" )
182
183
select {
183
184
case err := <- cmdExitChan :
185
+ terminal .Logger .Debug ().Msg ("Received exit (first boot)" )
184
186
if err != nil {
185
187
return errors .Wrapf (err , `command "%s" failed early` , r .pidFile )
186
188
}
@@ -191,6 +193,7 @@ func (r *Runner) Run() error {
191
193
// finished later one
192
194
go func () { cmdExitChan <- err }()
193
195
case <- timer .C :
196
+ terminal .Logger .Debug ().Msg ("Received timer message (first boot)" )
194
197
}
195
198
}
196
199
@@ -218,28 +221,34 @@ func (r *Runner) Run() error {
218
221
}
219
222
return err
220
223
case <- restartChan :
224
+ terminal .Logger .Debug ().Msg ("Received restart" )
221
225
// We use SIGTERM here because it's nicer and thus when we use our
222
226
// wrappers, signal will be nicely forwarded
223
227
cmd .Process .Signal (syscall .SIGTERM )
224
228
// we need to drain cmdExit channel to unblock cmd channel receiver
225
229
<- cmdExitChan
226
230
// Command exited
227
231
case err := <- cmdExitChan :
232
+ terminal .Logger .Debug ().Msg ("Received exit" )
228
233
err = errors .Wrapf (err , `command "%s" failed` , r .pidFile )
229
234
230
235
if err == nil && r .SuccessHook != nil {
236
+ terminal .Logger .Debug ().Msg ("Running success hook" )
231
237
r .SuccessHook (r , cmd )
232
238
}
233
239
234
240
// Command is NOT set up to loop, stop here and remove the pidFile
235
241
// if the command is successful
236
242
if ! looping {
237
243
if err != nil {
244
+ terminal .Logger .Debug ().Msg ("Not looping, exiting with error" )
238
245
return err
239
246
}
240
247
248
+ terminal .Logger .Debug ().Msg ("Removing pid file" )
241
249
return r .pidFile .Remove ()
242
250
}
251
+ terminal .Logger .Debug ().Msg ("Looping" )
243
252
244
253
// Command is set up to restart on exit (usually PHP builtin
245
254
// server), so we restart immediately without waiting
@@ -258,13 +267,16 @@ func (r *Runner) Run() error {
258
267
259
268
// Wait for a timer to expire or a file to be changed to restart
260
269
// or a signal to be received to exit
270
+ terminal .Logger .Debug ().Msg ("Waiting for channels" )
261
271
select {
262
272
case sig := <- sigChan :
263
273
terminal .Logger .Info ().Msgf (`Signal "%s" received, exiting` , sig )
264
274
return nil
265
275
case <- restartChan :
276
+ terminal .Logger .Debug ().Msg ("Received restart" )
266
277
timer .Stop ()
267
278
case <- timer .C :
279
+ terminal .Logger .Debug ().Msg ("Received timer message" )
268
280
}
269
281
}
270
282
0 commit comments