@@ -254,36 +254,23 @@ func (r *Runner) Run() error {
254
254
logger .Debug ().Msg ("Removing pid file" )
255
255
return r .pidFile .Remove ()
256
256
}
257
- logger .Debug ().Msg ("Looping" )
258
257
259
- // Command is set up to restart on exit (usually PHP builtin
260
- // server), so we restart immediately without waiting
258
+ // Command is set up to restart on exit (usually PHP builtin server)
261
259
if r .AlwaysRestartOnExit {
262
- logger .Error ().Msg ("command exited, restarting it immediately" )
260
+ logger .Debug ().Msg ("Looping" )
261
+ // In case of error we want to wait up-to 5 seconds before
262
+ // restarting the command, this avoids overloading the system with a
263
+ // failing command
264
+ if err != nil {
265
+ logger .Error ().Msgf (`command exited: %s, waiting 5 seconds before restarting it` , err )
266
+ timer .Reset (5 * time .Second )
267
+ } else {
268
+ logger .Error ().Msg ("command exited, restarting it immediately" )
269
+ }
263
270
continue
264
271
}
265
272
266
- // In case of error we want to wait up-to 5 seconds before
267
- // restarting the command, this avoids overloading the system with a
268
- // failing command
269
- if err != nil {
270
- logger .Error ().Msgf (`command exited: %s, waiting 5 seconds before restarting it` , err )
271
- timer .Reset (5 * time .Second )
272
- }
273
-
274
- // Wait for a timer to expire or a file to be changed to restart
275
- // or a signal to be received to exit
276
- logger .Debug ().Msg ("Waiting for channels" )
277
- select {
278
- case sig := <- sigChan :
279
- logger .Info ().Msgf (`Signal "%s" received, exiting` , sig )
280
- return nil
281
- case <- restartChan :
282
- logger .Debug ().Msg ("Received restart" )
283
- timer .Stop ()
284
- case <- timer .C :
285
- logger .Debug ().Msg ("Received timer message" )
286
- }
273
+ return nil
287
274
}
288
275
289
276
logger .Info ().Msg ("Restarting command" )
0 commit comments