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

Method Start

pkg/app/master/inspectors/probes/http/custom_probe.go:239–589  ·  view source on GitHub ↗

Start starts the HTTP probe instance execution

()

Source from the content-addressed store, hash-verified

237
238// Start starts the HTTP probe instance execution
239func (p *CustomProbe) Start() {
240 if p.printState {
241 p.xc.Out.State("http.probe.starting",
242 ovars{
243 "message": "WAIT FOR HTTP PROBE TO FINISH",
244 })
245 }
246
247 go func() {
248 //TODO: need to do a better job figuring out if the target app is ready to accept connections
249 time.Sleep(9 * time.Second) //base start wait time
250 if p.opts.StartWait > 0 {
251 if p.printState {
252 p.xc.Out.State("http.probe.start.wait", ovars{"time": p.opts.StartWait})
253 }
254
255 //additional wait time
256 time.Sleep(time.Duration(p.opts.StartWait) * time.Second)
257
258 if p.printState {
259 p.xc.Out.State("http.probe.start.wait.done")
260 }
261 }
262
263 if p.printState {
264 p.xc.Out.State("http.probe.running")
265 }
266
267 log.Info("HTTP probe started...")
268
269 findIdx := func(ports []string, target string) int {
270 for idx, val := range ports {
271 if val == target {
272 return idx
273 }
274 }
275 return -1
276 }
277
278 httpIdx := findIdx(p.ports, defaultHTTPPortStr)
279 httpsIdx := findIdx(p.ports, defaultHTTPSPortStr)
280 if httpIdx != -1 && httpsIdx != -1 && httpsIdx < httpIdx {
281 //want to probe http first
282 log.Debugf("http.probe - swapping http and https ports (http=%v <-> https=%v)",
283 httpIdx, httpsIdx)
284
285 p.ports[httpIdx], p.ports[httpsIdx] = p.ports[httpsIdx], p.ports[httpIdx]
286 }
287
288 if p.printState {
289 p.xc.Out.Info("http.probe.ports",
290 ovars{
291 "count": len(p.ports),
292 "targets": strings.Join(p.ports, ","),
293 })
294
295 var cmdListPreview []string
296 var cmdListTail string

Callers 1

OnCommandFunction · 0.95

Calls 15

ConnectMethod · 0.95
CheckConnectionMethod · 0.95
WriteStringMethod · 0.95
DisconnectMethod · 0.95
probeAPISpecsMethod · 0.95
crawlMethod · 0.95
IsValidWSProtoFunction · 0.85
NewWebsocketClientFunction · 0.85
getFastCGIClientFunction · 0.85
getHTTPClientFunction · 0.85
getHTTPAddrFunction · 0.85
newHTTPRequestFromCmdFunction · 0.85

Tested by

no test coverage detected