| @@ 313-329 (lines=17) @@ | ||
| 310 | }); |
|
| 311 | } |
|
| 312 | ||
| 313 | public function killProcessByPid($pid) |
|
| 314 | { |
|
| 315 | if ($this->isWindows()) { |
|
| 316 | $cmd = 'taskkill /F /PID %d'; |
|
| 317 | } else { |
|
| 318 | $cmd = 'kill -9 %d'; |
|
| 319 | } |
|
| 320 | ||
| 321 | $cmd = sprintf($cmd, $pid); |
|
| 322 | ||
| 323 | $output = $this->output; |
|
| 324 | ||
| 325 | $process = new Process($cmd, SeleniumSetup::$APP_ROOT_PATH, SeleniumSetup::$APP_PROCESS_ENV, null, null); |
|
| 326 | $process->run(function($type, $line) use ($output) { |
|
| 327 | $output->write($line); |
|
| 328 | }); |
|
| 329 | } |
|
| 330 | ||
| 331 | public function killProcessByName($processName) |
|
| 332 | { |
|
| @@ 331-347 (lines=17) @@ | ||
| 328 | }); |
|
| 329 | } |
|
| 330 | ||
| 331 | public function killProcessByName($processName) |
|
| 332 | { |
|
| 333 | if ($this->isWindows()) { |
|
| 334 | $cmd = 'taskkill /F /IM %s'; |
|
| 335 | } else { |
|
| 336 | $cmd = 'pgrep -f "%s" | xargs kill'; |
|
| 337 | } |
|
| 338 | ||
| 339 | $cmd = sprintf($cmd, $processName); |
|
| 340 | ||
| 341 | $output = $this->output; |
|
| 342 | ||
| 343 | $process = new Process($cmd, SeleniumSetup::$APP_ROOT_PATH, SeleniumSetup::$APP_PROCESS_ENV, null, null); |
|
| 344 | $process->run(function($type, $line) use ($output) { |
|
| 345 | $output->write($line); |
|
| 346 | }); |
|
| 347 | } |
|
| 348 | ||
| 349 | public function listenToPort($port) |
|
| 350 | { |
|
| @@ 349-368 (lines=20) @@ | ||
| 346 | }); |
|
| 347 | } |
|
| 348 | ||
| 349 | public function listenToPort($port) |
|
| 350 | { |
|
| 351 | if ($this->isWindows()) { |
|
| 352 | $cmd = 'netstat -ano|findstr :%d'; |
|
| 353 | } else { |
|
| 354 | $cmd = 'netstat -tulpn | grep :%d'; |
|
| 355 | } |
|
| 356 | ||
| 357 | $cmd = sprintf($cmd, $port); |
|
| 358 | ||
| 359 | $output = new BufferedOutput(); |
|
| 360 | ||
| 361 | $process = new Process($cmd, SeleniumSetup::$APP_ROOT_PATH, SeleniumSetup::$APP_PROCESS_ENV, null, null); |
|
| 362 | $process->run(function($type, $line) use ($output) { |
|
| 363 | $output->write($line); |
|
| 364 | }); |
|
| 365 | ||
| 366 | return $output->fetch(); |
|
| 367 | ||
| 368 | } |
|
| 369 | ||
| 370 | public function getPidFromListeningToPort($port) |
|
| 371 | { |
|