8000 Merge pull request #477 from symfony-cli/local-runner-comments · symfony-cli/symfony-cli@96d4e1d · GitHub
[go: up one dir, main page]

Skip to content

Commit 96d4e1d

Browse files
authored
Merge pull request #477 from symfony-cli/local-runner-comments
Add debug logs on the local runner
2 parents 915e1ad + 2c8f3bc commit 96d4e1d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

local/runner.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,8 +179,10 @@ func (r *Runner) Run() error {
179179
reexec.NotifyForeground("started")
180180
}
181181

182+
terminal.Logger.Debug().Msg("Waiting for channels (first boot)")
182183
select {
183184
case err := <-cmdExitChan:
185+
terminal.Logger.Debug().Msg("Received exit (first boot)")
184186
if err != nil {
185187
return errors.Wrapf(err, `command "%s" failed early`, r.pidFile)
186188
}
@@ -191,6 +193,7 @@ func (r *Runner) Run() error {
191193
// finished later one
192194
go func() { cmdExitChan <- err }()
193195
case <-timer.C:
196+
terminal.Logger.Debug().Msg("Received timer message (first boot)")
194197
}
195198
}
196199

@@ -218,28 +221,34 @@ func (r *Runner) Run() error {
218221
}
219222
return err
220223
case <-restartChan:
224+
terminal.Logger.Debug().Msg("Received restart")
221225
// We use SIGTERM here because it's nicer and thus when we use our
222226
// wrappers, signal will be nicely forwarded
223227
cmd.Process.Signal(syscall.SIGTERM)
224228
// we need to drain cmdExit channel to unblock cmd channel receiver
225229
<-cmdExitChan
226230
// Command exited
227231
case err := <-cmdExitChan:
232+
terminal.Logger.Debug().Msg("Received exit")
228233
err = errors.Wrapf(err, `command "%s" failed`, r.pidFile)
229234

230235
if err == nil && r.SuccessHook != nil {
236+
terminal.Logger.Debug().Msg("Running success hook")
231237
r.SuccessHook(r, cmd)
232238
}
233239

234240
// Command is NOT set up to loop, stop here and remove the pidFile
235241
// if the command is successful
236242
if !looping {
237243
if err != nil {
244+
terminal.Logger.Debug().Msg("Not looping, exiting with error")
238245
return err
239246
}
240247

248+
terminal.Logger.Debug().Msg("Removing pid file")
241249
return r.pidFile.Remove()
242250
}
251+
terminal.Logger.Debug().Msg("Looping")
243252

244253
// Command is set up to restart on exit (usually PHP builtin
245254
// server), so we restart immediately without waiting
@@ -258,13 +267,16 @@ func (r *Runner) Run() error {
258267

259268
// Wait for a timer to expire or a file to be changed to restart
260269
// or a signal to be received to exit
270+
terminal.Logger.Debug().Msg("Waiting for channels")
261271
select {
262272
case sig := <-sigChan:
263273
terminal.Logger.Info().Msgf(`Signal "%s" received, exiting`, sig)
264274
return nil
265275
case <-restartChan:
276+
terminal.Logger.Debug().Msg("Received restart")
266277
timer.Stop()
267278
case <-timer.C:
279+
terminal.Logger.Debug().Msg("Received timer message")
268280
}
269281
}
270282

0 commit comments

Comments
 (0)
0