()
| 63 | } |
| 64 | |
| 65 | func (s *Sensor) Run() error { |
| 66 | s.exe.HookSensorPostStart() |
| 67 | |
| 68 | err := s.run() |
| 69 | if err != nil { |
| 70 | s.exe.PubEvent(event.Error, err.Error()) |
| 71 | } |
| 72 | |
| 73 | // We have to dump the artifacts before invokin the pre-shutdown |
| 74 | // hook - it may want to upload the artifacts somewhere. |
| 75 | errutil.WarnOn(s.artifactor.Archive()) |
| 76 | |
| 77 | s.exe.HookSensorPreShutdown() |
| 78 | s.exe.PubEvent(event.ShutdownSensorDone) |
| 79 | |
| 80 | // The target app can be done before the stop signal is received |
| 81 | // because of two reasons: |
| 82 | // |
| 83 | // - App terminated on its own (e.g., a typical CLI use case) |
| 84 | // |
| 85 | // - The "stop monitor" control command was received. |
| 86 | // |
| 87 | // In the latter case, sensor needs to wait for the stop signal |
| 88 | // before proceeding with the shutdown because otherwise the container |
| 89 | // runtime may restart the container which is not desirable. |
| 90 | if s.stopCommandReceived { |
| 91 | select { |
| 92 | case <-s.ctx.Done(): |
| 93 | case <-s.signalCh: |
| 94 | } |
| 95 | } |
| 96 | |
| 97 | return err |
| 98 | } |
| 99 | |
| 100 | func (s *Sensor) run() error { |
| 101 | raw := <-s.exe.Commands() |
nothing calls this directly
no test coverage detected