Start starts the HTTP probe instance execution
()
| 237 | |
| 238 | // Start starts the HTTP probe instance execution |
| 239 | func (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 |
no test coverage detected