MCPcopy
hub / github.com/slimtoolkit/slim / run

Method run

pkg/app/sensor/controlled/controlled.go:83–113  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

81}
82
83func (s *Sensor) run() error {
84 log.Info("sensor: waiting for commands...")
85
86 for {
87 mon, err := s.runWithoutMonitor()
88 if err != nil {
89 s.exe.HookMonitorFailed()
90 s.exe.PubEvent(event.StartMonitorFailed,
91 &event.StartMonitorFailedData{
92 Component: event.ComMonitorRunner, //TODO: need to get to the real component
93 State: s.exe.State(),
94 Errors: []string{err.Error()},
95 })
96
97 return fmt.Errorf("run sensor without monitor failed: %w", err)
98 }
99
100 if mon == nil {
101 return nil
102 }
103
104 s.exe.PubEvent(event.StartMonitorDone)
105
106 if err := s.runWithMonitor(mon); err != nil {
107 return fmt.Errorf("run sensor with monitor failed: %w", err)
108 }
109
110 s.exe.HookMonitorPostShutdown()
111 s.exe.PubEvent(event.StopMonitorDone)
112 }
113}
114
115func (s *Sensor) runWithoutMonitor() (monitor.CompositeMonitor, error) {
116 ticker := time.NewTicker(5 * time.Second)

Callers 1

RunMethod · 0.95

Calls 8

runWithoutMonitorMethod · 0.95
runWithMonitorMethod · 0.95
HookMonitorFailedMethod · 0.65
PubEventMethod · 0.65
StateMethod · 0.65
InfoMethod · 0.45
ErrorMethod · 0.45

Tested by

no test coverage detected