From e3395cb3ac6f579c3707ed50481e3517ac98729e Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 21:30:57 +0530 Subject: [PATCH 01/43] updated s3 logs --- .travis.yml | 6 ++++++ lib/LocalBinary.php | 8 ++++---- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/.travis.yml b/.travis.yml index 559c799..cc8dab5 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,5 +1,11 @@ language: php +php: + - '5.4' + - '5.5' + - '5.6' + - '7.0' + before_install: - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==` diff --git a/lib/LocalBinary.php b/lib/LocalBinary.php index 591c34b..28e5497 100644 --- a/lib/LocalBinary.php +++ b/lib/LocalBinary.php @@ -50,14 +50,14 @@ private function server_home() { private function platform_url(){ if (PHP_OS == "Darwin") - return "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-darwin-x64"; + return 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-darwin-x64'; else if (strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') - return "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal.exe"; + return 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-win32.exe'; if ((strtoupper(PHP_OS)) == "LINUX") { if (PHP_INT_SIZE * 8 == 64) - return "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-x64"; + return 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-x64'; else - return "https://s3.amazonaws.com/browserStack/browserstack-local/BrowserStackLocal-linux-ia32"; + return 'https://s3.amazonaws.com/bs-automate-prod/local/BrowserStackLocal-linux-ia32'; } } From 4da088235f13a621977480d975521cd75ac55526 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 21:35:35 +0530 Subject: [PATCH 02/43] added phpunit xml --- phpunit.xml | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 phpunit.xml diff --git a/phpunit.xml b/phpunit.xml new file mode 100644 index 0000000..c5544cc --- /dev/null +++ b/phpunit.xml @@ -0,0 +1,8 @@ + + + + tests + + + + From da9642700314c6f34834cf32f353ba9c6c628cd7 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 21:35:54 +0530 Subject: [PATCH 03/43] updated readme --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index cc76816..3a779b4 100644 --- a/README.md +++ b/README.md @@ -52,6 +52,6 @@ Test the installation by running a simple test file, check out example.php in th Testing is possible using [PHPUnit](https://phpunit.de/). To run the tests, run the command: - `phpunit tests/LocalTest.php` + `phpunit` From 7143a2ebf5a1822b2f31266291355d501b0f794a Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 21:39:24 +0530 Subject: [PATCH 04/43] added composer install --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index cc8dab5..dd6b95f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -8,4 +8,5 @@ php: before_install: - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==` + - true && composer install From 6bb8eac87c6821c769908710a70a034a5e57922c Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 21:45:05 +0530 Subject: [PATCH 05/43] use php 5.5 --- .travis.yml | 3 --- 1 file changed, 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index dd6b95f..b56bdce 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,10 +1,7 @@ language: php php: - - '5.4' - '5.5' - - '5.6' - - '7.0' before_install: - true && `base64 --decode <<< ZXhwb3J0IEJST1dTRVJTVEFDS19BQ0NFU1NfS0VZPUh5VmZydXJvb3dYb041eGhLZEs2Cg==` From 85851f721029f27e69bf1c8bac69d1a232bf6881 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 21:48:03 +0530 Subject: [PATCH 06/43] disable multiple binary check --- tests/LocalTest.php | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 00c484f..0da4c3e 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -65,23 +65,23 @@ public function test_hosts() { $this->assertContains('localhost,8080,0',$this->bs_local->command()); } - public function test_multiple_binary() { - $this->bs_local->start(array('v' => true)); - $bs_local_2 = new Local(); - try { - $bs_local_2->start(array('v' => true)); - } catch (LocalException $ex) { - $emessage = $ex->getMessage(); - $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); - $bs_local_2->stop(); - $this->bs_local->stop(); - sleep(2); - return; - } - $this->fail("Expected Exception has not been raised."); - $this->bs_local->stop(); - sleep(2); - } + // public function test_multiple_binary() { + // $this->bs_local->start(array('v' => true)); + // $bs_local_2 = new Local(); + // try { + // $bs_local_2->start(array('v' => true)); + // } catch (LocalException $ex) { + // $emessage = $ex->getMessage(); + // $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); + // $bs_local_2->stop(); + // $this->bs_local->stop(); + // sleep(2); + // return; + // } + // $this->fail("Expected Exception has not been raised."); + // $this->bs_local->stop(); + // sleep(2); + // } public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); From 1c6cdefa10d321069e283522d32560f395645b4c Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:04:45 +0530 Subject: [PATCH 07/43] download issue --- lib/LocalBinary.php | 15 ++++++++++++--- tests/LocalTest.php | 34 +++++++++++++++++----------------- 2 files changed, 29 insertions(+), 20 deletions(-) diff --git a/lib/LocalBinary.php b/lib/LocalBinary.php index 28e5497..8f780e4 100644 --- a/lib/LocalBinary.php +++ b/lib/LocalBinary.php @@ -65,8 +65,18 @@ public function download_binary($path) { $url = $this->platform_url(); if (!file_exists($path)) mkdir($path, 0777, true); + + $ch = curl_init(); + curl_setopt($ch, CURLOPT_URL, $url); + curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1); + $data = curl_exec ($ch); + curl_close ($ch); + + $file = fopen($path . '/BrowserStackLocal', "w+"); + fputs($file, $data); + fclose($file); - file_put_contents($path . '/BrowserStackLocal', fopen($url, 'r')); + chmod($path . '/BrowserStackLocal', 0755); return $path . "/BrowserStackLocal"; } @@ -74,8 +84,7 @@ private function get_available_dirs() { $arrlength = count($this->possible_binary_paths); for($x = 0; $x < $arrlength; $x++) { $path = $this->possible_binary_paths[$x]; - $localpath = $path . "/BrowserStackLocal"; - if(file_exists($localpath) || $this->make_path($path)) + if(file_exists($path) || $this->make_path($path)) return $path; } throw new LocalException("Error trying to download BrowserStack Local binary"); diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 0da4c3e..00c484f 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -65,23 +65,23 @@ public function test_hosts() { $this->assertContains('localhost,8080,0',$this->bs_local->command()); } - // public function test_multiple_binary() { - // $this->bs_local->start(array('v' => true)); - // $bs_local_2 = new Local(); - // try { - // $bs_local_2->start(array('v' => true)); - // } catch (LocalException $ex) { - // $emessage = $ex->getMessage(); - // $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); - // $bs_local_2->stop(); - // $this->bs_local->stop(); - // sleep(2); - // return; - // } - // $this->fail("Expected Exception has not been raised."); - // $this->bs_local->stop(); - // sleep(2); - // } + public function test_multiple_binary() { + $this->bs_local->start(array('v' => true)); + $bs_local_2 = new Local(); + try { + $bs_local_2->start(array('v' => true)); + } catch (LocalException $ex) { + $emessage = $ex->getMessage(); + $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); + $bs_local_2->stop(); + $this->bs_local->stop(); + sleep(2); + return; + } + $this->fail("Expected Exception has not been raised."); + $this->bs_local->stop(); + sleep(2); + } public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); From 8bdb2565d371241f82072173cb64b7a039682b6f Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:10:21 +0530 Subject: [PATCH 08/43] stop fix --- lib/Local.php | 2 ++ 1 file changed, 2 insertions(+) diff --git a/lib/Local.php b/lib/Local.php index 5c262e7..33b67af 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -103,6 +103,8 @@ public function stop() { return; else proc_terminate($this->handle); + while($this->isRunning()) + sleep(1); } public function command() { From 1f7ce110268d1bc66bf5bf220dc2383dd9fbc7be Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:14:19 +0530 Subject: [PATCH 09/43] more fixes --- lib/Local.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index 33b67af..a4c93b4 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -86,10 +86,11 @@ public function start($arguments) { $buffer = fread($this->loghandle, 1024); if (preg_match("/Error:[^\n]+/i", $buffer, $match)) { throw new LocalException($match[0]); - proc_terminate($this->handle); + $this->stop(); break; } elseif (preg_match("/\bPress Ctrl-C to exit\b/i", $buffer, $match)) + fclose($this->loghandle); break; //flush(); From fdc2623b350d7a2d076e59203defc1832e82dcfb Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:30:30 +0530 Subject: [PATCH 10/43] fixes tearDown --- lib/Local.php | 5 +++-- tests/LocalTest.php | 14 +++++--------- 2 files changed, 8 insertions(+), 11 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index a4c93b4..61bcff7 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -85,13 +85,14 @@ public function start($arguments) { while (true) { $buffer = fread($this->loghandle, 1024); if (preg_match("/Error:[^\n]+/i", $buffer, $match)) { - throw new LocalException($match[0]); $this->stop(); + throw new LocalException($match[0]); break; } - elseif (preg_match("/\bPress Ctrl-C to exit\b/i", $buffer, $match)) + elseif (preg_match("/\bPress Ctrl-C to exit\b/i", $buffer, $match)){ fclose($this->loghandle); break; + } //flush(); sleep(1); diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 00c484f..1267997 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -17,6 +17,10 @@ public function setUp(){ $this->bs_local = new Local(); } + public function tearDown(){ + $this->bs_local->stop(); + } + public function test_verbose() { $this->bs_local->add_args('v'); $this->assertContains('-v',$this->bs_local->command()); @@ -70,25 +74,17 @@ public function test_multiple_binary() { $bs_local_2 = new Local(); try { $bs_local_2->start(array('v' => true)); + $this->fail("Expected Exception has not been raised."); } catch (LocalException $ex) { $emessage = $ex->getMessage(); $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); - $bs_local_2->stop(); - $this->bs_local->stop(); - sleep(2); return; } - $this->fail("Expected Exception has not been raised."); - $this->bs_local->stop(); - sleep(2); } public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); $this->bs_local->start(array('v' => true)); $this->assertTrue($this->bs_local->isRunning()); - $this->bs_local->stop(); - sleep(2); - $this->assertFalse($this->bs_local->isRunning()); } } From 407a5e620e4c18010bb26361e78262d368a5da98 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:32:49 +0530 Subject: [PATCH 11/43] check only is running --- tests/LocalTest.php | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 1267997..56c322e 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -69,18 +69,18 @@ public function test_hosts() { $this->assertContains('localhost,8080,0',$this->bs_local->command()); } - public function test_multiple_binary() { - $this->bs_local->start(array('v' => true)); - $bs_local_2 = new Local(); - try { - $bs_local_2->start(array('v' => true)); - $this->fail("Expected Exception has not been raised."); - } catch (LocalException $ex) { - $emessage = $ex->getMessage(); - $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); - return; - } - } + // public function test_multiple_binary() { + // $this->bs_local->start(array('v' => true)); + // $bs_local_2 = new Local(); + // try { + // $bs_local_2->start(array('v' => true)); + // $this->fail("Expected Exception has not been raised."); + // } catch (LocalException $ex) { + // $emessage = $ex->getMessage(); + // $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); + // return; + // } + // } public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); From 26288af7f291dd1cceb15fb5f4558095e9e5b693 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:35:07 +0530 Subject: [PATCH 12/43] readd multiple binary test --- tests/LocalTest.php | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 56c322e..f83fa71 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -69,22 +69,22 @@ public function test_hosts() { $this->assertContains('localhost,8080,0',$this->bs_local->command()); } - // public function test_multiple_binary() { - // $this->bs_local->start(array('v' => true)); - // $bs_local_2 = new Local(); - // try { - // $bs_local_2->start(array('v' => true)); - // $this->fail("Expected Exception has not been raised."); - // } catch (LocalException $ex) { - // $emessage = $ex->getMessage(); - // $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); - // return; - // } - // } - public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); $this->bs_local->start(array('v' => true)); $this->assertTrue($this->bs_local->isRunning()); } + + public function test_multiple_binary() { + $this->bs_local->start(array('v' => true)); + $bs_local_2 = new Local(); + try { + $bs_local_2->start(array('v' => true)); + $this->fail("Expected Exception has not been raised."); + } catch (LocalException $ex) { + $emessage = $ex->getMessage(); + $this->assertEquals(trim($emessage), 'Error: Either another browserstack local client is running on your machine or some server is listening on port 45691'); + return; + } + } } From 6a2f59a61b5c823a034a5c86223cbbd30323128a Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:39:12 +0530 Subject: [PATCH 13/43] try sleep --- tests/LocalTest.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index f83fa71..0fd949a 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -19,6 +19,7 @@ public function setUp(){ public function tearDown(){ $this->bs_local->stop(); + sleep(5); } public function test_verbose() { From e8875a3e3cc8b15561e811dced355dd3645a80a9 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 22:41:11 +0530 Subject: [PATCH 14/43] try sleep --- lib/Local.php | 8 +++++--- tests/LocalTest.php | 1 - 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 61bcff7..f2fd71c 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -103,10 +103,12 @@ public function stop() { fclose($this->loghandle); if (is_null($this->handle)) return; - else + else { proc_terminate($this->handle); - while($this->isRunning()) - sleep(1); + while($this->isRunning()) + sleep(1); + sleep(5); + } } public function command() { diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 0fd949a..f83fa71 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -19,7 +19,6 @@ public function setUp(){ public function tearDown(){ $this->bs_local->stop(); - sleep(5); } public function test_verbose() { From ed98e77667d37a3340fb74a0868def78ae168c99 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Tue, 1 Mar 2016 23:59:03 +0530 Subject: [PATCH 15/43] proc close wait to close --- lib/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index f2fd71c..e97b70d 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -105,9 +105,9 @@ public function stop() { return; else { proc_terminate($this->handle); + proc_close($this->handle); while($this->isRunning()) sleep(1); - sleep(5); } } From 044b9edd4c691caf6b64966a0ff1b1125423dc5a Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 00:41:49 +0530 Subject: [PATCH 16/43] added posix kill --- example.php | 4 ++++ lib/Local.php | 14 +++++++++++--- tests/LocalTest.php | 6 ++++++ 3 files changed, 21 insertions(+), 3 deletions(-) diff --git a/example.php b/example.php index 8d6225f..1d77952 100644 --- a/example.php +++ b/example.php @@ -10,8 +10,12 @@ $me = new Local(); $me->isRunning(); +echo "starting"; $args = array("v" => 1); $me->start($args); +echo "started"; echo $me->isRunning(); +echo "stopping"; $me->stop(); +echo "stopped"; echo $me->isRunning(); diff --git a/lib/Local.php b/lib/Local.php index e97b70d..8284539 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -73,14 +73,17 @@ public function start($arguments) { $this->binary_path = $this->binary->binary_path(); $descriptorspec = array( - 0 => array("pipe", "r"), // stdin is a pipe that the child will read from - 1 => array("pipe", "w"), // stdout is a pipe that the child will write to - 2 => array("file", "/tmp/error-output.txt", "a") // stderr is a file to write to + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") ); $call = $this->command(); system('echo "" > '. $this->logfile); $this->handle = proc_open($call, $descriptorspec, $this->pipes); + $status = proc_get_status($this->handle); + $this->pid = $status['pid']; + $this->loghandle = fopen($this->logfile,"r"); while (true) { $buffer = fread($this->loghandle, 1024); @@ -104,8 +107,13 @@ public function stop() { if (is_null($this->handle)) return; else { + fclose($this->pipes[0]); + fclose($this->pipes[1]); + fclose($this->pipes[2]); + proc_terminate($this->handle); proc_close($this->handle); + posix_kill($this->pid, SIGKILL); while($this->isRunning()) sleep(1); } diff --git a/tests/LocalTest.php b/tests/LocalTest.php index f83fa71..686467b 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -69,6 +69,12 @@ public function test_hosts() { $this->assertContains('localhost,8080,0',$this->bs_local->command()); } + public function test_checkPid() { + $this->assertFalse($this->bs_local->isRunning()); + $this->bs_local->start(array('v' => true)); + $this->assertTrue($this->bs_local->pid > 0); + } + public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); $this->bs_local->start(array('v' => true)); From cfd01885f1f8502a2b4e2ed546d3e164a8b03f7c Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 00:47:03 +0530 Subject: [PATCH 17/43] sigterm --- lib/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index 8284539..ea31c94 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,7 +113,7 @@ public function stop() { proc_terminate($this->handle); proc_close($this->handle); - posix_kill($this->pid, SIGKILL); + posix_kill($this->pid, SIGTERM); while($this->isRunning()) sleep(1); } From f64c0cd63f701cc66d5f6e9758f36e65a0cec3db Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 02:49:22 +0530 Subject: [PATCH 18/43] exec kill --- lib/Local.php | 3 ++- tests/LocalTest.php | 1 - 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index ea31c94..7d8659a 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,7 +113,8 @@ public function stop() { proc_terminate($this->handle); proc_close($this->handle); - posix_kill($this->pid, SIGTERM); + if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') + exec('kill -9 ' . $this->pid); while($this->isRunning()) sleep(1); } diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 686467b..8391ce0 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -1,5 +1,4 @@ Date: Wed, 2 Mar 2016 03:01:15 +0530 Subject: [PATCH 19/43] kill int --- lib/Local.php | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 7d8659a..0539f74 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -73,9 +73,9 @@ public function start($arguments) { $this->binary_path = $this->binary->binary_path(); $descriptorspec = array( - 0 => array("pipe", "r"), - 1 => array("pipe", "w"), - 2 => array("pipe", "w") + // 0 => array("pipe", "r"), + // 1 => array("pipe", "w"), + // 2 => array("pipe", "w") ); $call = $this->command(); @@ -107,14 +107,14 @@ public function stop() { if (is_null($this->handle)) return; else { - fclose($this->pipes[0]); - fclose($this->pipes[1]); - fclose($this->pipes[2]); + // fclose($this->pipes[0]); + // fclose($this->pipes[1]); + // fclose($this->pipes[2]); + if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') + exec('kill -2 ' . $this->pid); proc_terminate($this->handle); proc_close($this->handle); - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - exec('kill -9 ' . $this->pid); while($this->isRunning()) sleep(1); } From 24bdfa665b3f7972648d5fca8e368b43c7373d6c Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 03:05:36 +0530 Subject: [PATCH 20/43] kill int --- lib/Local.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Local.php b/lib/Local.php index 0539f74..f2bc455 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -13,6 +13,7 @@ class Local { private $handle = NULL; private $pipes = array(); private $loghandle = NULL; + private $pid = NULL; public function __construct() { $this->key = getenv("BROWSERSTACK_ACCESS_KEY"); From 15bdf45340889a3c1cd0affb08d94d94a8bf2fd5 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 03:07:11 +0530 Subject: [PATCH 21/43] kill int --- lib/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index f2bc455..c16644d 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -13,7 +13,7 @@ class Local { private $handle = NULL; private $pipes = array(); private $loghandle = NULL; - private $pid = NULL; + public $pid = NULL; public function __construct() { $this->key = getenv("BROWSERSTACK_ACCESS_KEY"); From d6606779ccfb8801c517c5ffbf410145a9a1ceb0 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 11:33:14 +0530 Subject: [PATCH 22/43] stricter is running --- lib/Local.php | 4 ++-- tests/LocalTest.php | 12 ++++++++---- 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index c16644d..ef3e27e 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -28,7 +28,7 @@ public function isRunning() { return False; $status = proc_get_status($this->handle); - return $status["running"]; + return !is_null($status["running"]); } public function add_args($arg_key, $value = NULL) { @@ -113,7 +113,7 @@ public function stop() { // fclose($this->pipes[2]); if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - exec('kill -2 ' . $this->pid); + exec('kill -15 ' . $this->pid); proc_terminate($this->handle); proc_close($this->handle); while($this->isRunning()) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index 8391ce0..f5b9a04 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -68,16 +68,20 @@ public function test_hosts() { $this->assertContains('localhost,8080,0',$this->bs_local->command()); } - public function test_checkPid() { + public function test_isRunning() { $this->assertFalse($this->bs_local->isRunning()); $this->bs_local->start(array('v' => true)); - $this->assertTrue($this->bs_local->pid > 0); + $this->assertTrue($this->bs_local->isRunning()); + $this->bs_local->stop(); + $this->assertFalse($this->bs_local->isRunning()); + $this->bs_local->start(array('v' => true)); + $this->assertTrue($this->bs_local->isRunning()); } - public function test_isRunning() { + public function test_checkPid() { $this->assertFalse($this->bs_local->isRunning()); $this->bs_local->start(array('v' => true)); - $this->assertTrue($this->bs_local->isRunning()); + $this->assertTrue($this->bs_local->pid > 0); } public function test_multiple_binary() { From bca24538c1eda7b8961cfc41f137795019ff2635 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 11:39:39 +0530 Subject: [PATCH 23/43] read stdin pipe --- lib/Local.php | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index ef3e27e..e92abaf 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -74,9 +74,9 @@ public function start($arguments) { $this->binary_path = $this->binary->binary_path(); $descriptorspec = array( - // 0 => array("pipe", "r"), - // 1 => array("pipe", "w"), - // 2 => array("pipe", "w") + 0 => array("pipe", "r"), + 1 => array("pipe", "w"), + 2 => array("pipe", "w") ); $call = $this->command(); @@ -108,9 +108,10 @@ public function stop() { if (is_null($this->handle)) return; else { - // fclose($this->pipes[0]); - // fclose($this->pipes[1]); - // fclose($this->pipes[2]); + while(fgets($this->pipes[0])); + fclose($this->pipes[0]); + fclose($this->pipes[1]); + fclose($this->pipes[2]); if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -15 ' . $this->pid); From 40615b2029439bfa642fcd06d27422ae1eb8957e Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 11:43:06 +0530 Subject: [PATCH 24/43] added print --- lib/Local.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Local.php b/lib/Local.php index e92abaf..f3e5eae 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -28,6 +28,7 @@ public function isRunning() { return False; $status = proc_get_status($this->handle); + print_r($status); return !is_null($status["running"]); } From ae4491ae78bd0a4810481b14736a15d940f67e9a Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 11:52:23 +0530 Subject: [PATCH 25/43] try check status --- lib/Local.php | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index f3e5eae..9f4d909 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -28,8 +28,7 @@ public function isRunning() { return False; $status = proc_get_status($this->handle); - print_r($status); - return !is_null($status["running"]); + return is_null($status["running"]) ? false : $status["running"]; } public function add_args($arg_key, $value = NULL) { @@ -117,7 +116,13 @@ public function stop() { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -15 ' . $this->pid); proc_terminate($this->handle); - proc_close($this->handle); + $status = proc_get_status($this->handle); + echo "Stopping"; + print_r($status); + //proc_close($this->handle); + // $status = proc_get_status($this->handle); + // echo "Stopped"; + // print_r($status); while($this->isRunning()) sleep(1); } From 37543e3174c760f92d184438c6459b13085c6244 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:03:45 +0530 Subject: [PATCH 26/43] kill -2 --- lib/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index 9f4d909..70612e5 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -114,7 +114,7 @@ public function stop() { fclose($this->pipes[2]); if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - exec('kill -15 ' . $this->pid); + exec('kill -2 ' . $this->pid); proc_terminate($this->handle); $status = proc_get_status($this->handle); echo "Stopping"; From e19a6da713399b5b13c2a0773de8658c7bfe1235 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:04:53 +0530 Subject: [PATCH 27/43] kill -2 --- lib/Local.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 70612e5..6d91940 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,9 +113,9 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - exec('kill -2 ' . $this->pid); - proc_terminate($this->handle); + // if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') + // exec('kill -2 ' . $this->pid); + proc_terminate($this->handle, 2); $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); From 1e42fccf5a1980c03f874d88c2b9820404ff2b2f Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:07:50 +0530 Subject: [PATCH 28/43] no proc term --- lib/Local.php | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 6d91940..e0a20aa 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,9 +113,10 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); - // if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - // exec('kill -2 ' . $this->pid); - proc_terminate($this->handle, 2); + if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') + exec('kill -2 ' . $this->pid); + else + proc_terminate($this->handle); $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); From 13b2bced25671c392cbd2ba1d9d7ab6999e5099d Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:10:36 +0530 Subject: [PATCH 29/43] add proc close --- lib/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index e0a20aa..758f70f 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -120,7 +120,7 @@ public function stop() { $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); - //proc_close($this->handle); + proc_close($this->handle); // $status = proc_get_status($this->handle); // echo "Stopped"; // print_r($status); From 55b6967665a58fce13bc2bf1e22c7440192c7835 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:13:22 +0530 Subject: [PATCH 30/43] trying --- lib/Local.php | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 758f70f..dc05abf 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -115,8 +115,8 @@ public function stop() { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -2 ' . $this->pid); - else - proc_terminate($this->handle); + + proc_terminate($this->handle, 2); $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); From 7392ec223d7487c0e4adaacf317106f17d9a7e33 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:18:16 +0530 Subject: [PATCH 31/43] kill 15 --- lib/Local.php | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index dc05abf..35e09a1 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -114,16 +114,13 @@ public function stop() { fclose($this->pipes[2]); if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - exec('kill -2 ' . $this->pid); + exec('kill -15 ' . $this->pid); - proc_terminate($this->handle, 2); + proc_terminate($this->handle); $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); proc_close($this->handle); - // $status = proc_get_status($this->handle); - // echo "Stopped"; - // print_r($status); while($this->isRunning()) sleep(1); } From bcf452a03077a9f7bc10795c06b026eaaebe1309 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:22:04 +0530 Subject: [PATCH 32/43] echo command --- lib/Local.php | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 35e09a1..89e704c 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,10 +113,11 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); + echo 'kill -15 ' . $this->pid; if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -15 ' . $this->pid); - - proc_terminate($this->handle); + else + proc_terminate($this->handle); $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); From a7741c132bc31aabef3c1c8e2dae27ec299da181 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:36:48 +0530 Subject: [PATCH 33/43] added echo --- lib/Local.php | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/Local.php b/lib/Local.php index 89e704c..45405c7 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -121,6 +121,7 @@ public function stop() { $status = proc_get_status($this->handle); echo "Stopping"; print_r($status); + echo exec('ps aux| grep BrowserStackLocal'); proc_close($this->handle); while($this->isRunning()) sleep(1); From 9519529613d665f5010ee595b6035c4bd90e1466 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:47:32 +0530 Subject: [PATCH 34/43] try force for is running test --- lib/Local.php | 10 +--------- tests/LocalTest.php | 2 +- 2 files changed, 2 insertions(+), 10 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 45405c7..ea6411f 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,15 +113,7 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); - echo 'kill -15 ' . $this->pid; - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') - exec('kill -15 ' . $this->pid); - else - proc_terminate($this->handle); - $status = proc_get_status($this->handle); - echo "Stopping"; - print_r($status); - echo exec('ps aux| grep BrowserStackLocal'); + proc_terminate($this->handle); proc_close($this->handle); while($this->isRunning()) sleep(1); diff --git a/tests/LocalTest.php b/tests/LocalTest.php index f5b9a04..ce93361 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -74,7 +74,7 @@ public function test_isRunning() { $this->assertTrue($this->bs_local->isRunning()); $this->bs_local->stop(); $this->assertFalse($this->bs_local->isRunning()); - $this->bs_local->start(array('v' => true)); + $this->bs_local->start(array('v' => true, 'force' => true)); $this->assertTrue($this->bs_local->isRunning()); } From 20b57c8fec9cfb9f48f57c8e80307453d0921fd2 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 12:50:45 +0530 Subject: [PATCH 35/43] sig term --- lib/Local.php | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index ea6411f..f22f1c2 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,10 +113,13 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); - proc_terminate($this->handle); - proc_close($this->handle); + if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') + exec('kill -15 ' . $this->pid); + else + proc_terminate($this->handle); while($this->isRunning()) sleep(1); + proc_close($this->handle); } } From 4294f64c8027e90fbd3ab41d3d8ca697094cf9e1 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 13:05:07 +0530 Subject: [PATCH 36/43] proc close issue --- lib/Local.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index f22f1c2..5098c51 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -115,11 +115,11 @@ public function stop() { if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -15 ' . $this->pid); - else - proc_terminate($this->handle); + + proc_terminate($this->handle); + proc_close($this->handle); while($this->isRunning()) sleep(1); - proc_close($this->handle); } } From e06bfc9f0df01193eb3410e2320507acc43f63af Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 13:08:20 +0530 Subject: [PATCH 37/43] remove force --- tests/LocalTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index ce93361..f5b9a04 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -74,7 +74,7 @@ public function test_isRunning() { $this->assertTrue($this->bs_local->isRunning()); $this->bs_local->stop(); $this->assertFalse($this->bs_local->isRunning()); - $this->bs_local->start(array('v' => true, 'force' => true)); + $this->bs_local->start(array('v' => true)); $this->assertTrue($this->bs_local->isRunning()); } From a87d0d79cc2c4057aecc9b06d40de5b4ac85afda Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 13:10:37 +0530 Subject: [PATCH 38/43] add force --- tests/LocalTest.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/LocalTest.php b/tests/LocalTest.php index f5b9a04..ce93361 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -74,7 +74,7 @@ public function test_isRunning() { $this->assertTrue($this->bs_local->isRunning()); $this->bs_local->stop(); $this->assertFalse($this->bs_local->isRunning()); - $this->bs_local->start(array('v' => true)); + $this->bs_local->start(array('v' => true, 'force' => true)); $this->assertTrue($this->bs_local->isRunning()); } From 70ac51a0170f561f1d92af6aa5b31d45fa6e9256 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 13:14:49 +0530 Subject: [PATCH 39/43] no close --- lib/Local.php | 2 +- tests/LocalTest.php | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 5098c51..7d09641 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -117,7 +117,7 @@ public function stop() { exec('kill -15 ' . $this->pid); proc_terminate($this->handle); - proc_close($this->handle); + //proc_close($this->handle); while($this->isRunning()) sleep(1); } diff --git a/tests/LocalTest.php b/tests/LocalTest.php index ce93361..f5b9a04 100644 --- a/tests/LocalTest.php +++ b/tests/LocalTest.php @@ -74,7 +74,7 @@ public function test_isRunning() { $this->assertTrue($this->bs_local->isRunning()); $this->bs_local->stop(); $this->assertFalse($this->bs_local->isRunning()); - $this->bs_local->start(array('v' => true, 'force' => true)); + $this->bs_local->start(array('v' => true)); $this->assertTrue($this->bs_local->isRunning()); } From 999de91af4c27850be28b9f0cf556a4cca9a1cbf Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 14:43:52 +0530 Subject: [PATCH 40/43] added build status --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 3a779b4..f307c97 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # browserstack-local-php +[![Build Status](https://travis-ci.org/browserstack/browserstack-local-php.svg?branch=master)](https://travis-ci.org/browserstack/browserstack-local-php) + ## Setup Installation is possible using [Composer](https://getcomposer.org/). From e088bf341a38e3ebed8c0d9b4b13d710a96b197f Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 19:03:16 +0530 Subject: [PATCH 41/43] check ps aux debug --- lib/Local.php | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/Local.php b/lib/Local.php index 7d09641..b13f10e 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,11 +113,19 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); + echo `ps aux| grep BrowserStackLocal`; + echo `lsof -i:45691`; + echo $this->pid; + if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -15 ' . $this->pid); proc_terminate($this->handle); //proc_close($this->handle); + echo `ps aux| grep BrowserStackLocal`; + echo `lsof -i:45691`; + echo $this->pid; + while($this->isRunning()) sleep(1); } From 216f885ba601022b26fe4df01ce34999d888675a Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 19:17:48 +0530 Subject: [PATCH 42/43] use exec --- lib/Local.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/Local.php b/lib/Local.php index b13f10e..4d1b897 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -132,7 +132,7 @@ public function stop() { } public function command() { - $command = "$this->binary_path -logFile $this->logfile $this->folder_flag $this->key $this->folder_path $this->force_local_flag $this->local_identifier_flag $this->only_flag $this->only_automate_flag $this->proxy_host $this->proxy_port $this->proxy_user $this->proxy_pass $this->force_flag $this->verbose_flag $this->hosts"; + $command = "exec $this->binary_path -logFile $this->logfile $this->folder_flag $this->key $this->folder_path $this->force_local_flag $this->local_identifier_flag $this->only_flag $this->only_automate_flag $this->proxy_host $this->proxy_port $this->proxy_user $this->proxy_pass $this->force_flag $this->verbose_flag $this->hosts"; $command = preg_replace('/\s+/S', " ", $command); return $command; } From d3d3b4ea6ff4e49325abad5be6a9045569648c28 Mon Sep 17 00:00:00 2001 From: Vibhaj Rajan Date: Wed, 2 Mar 2016 19:26:05 +0530 Subject: [PATCH 43/43] fixes travis issues --- lib/Local.php | 16 ++++++---------- 1 file changed, 6 insertions(+), 10 deletions(-) diff --git a/lib/Local.php b/lib/Local.php index 4d1b897..399729e 100644 --- a/lib/Local.php +++ b/lib/Local.php @@ -113,26 +113,22 @@ public function stop() { fclose($this->pipes[1]); fclose($this->pipes[2]); - echo `ps aux| grep BrowserStackLocal`; - echo `lsof -i:45691`; - echo $this->pid; - if (strtoupper(substr(PHP_OS, 0, 3)) !== 'WIN') exec('kill -15 ' . $this->pid); proc_terminate($this->handle); - //proc_close($this->handle); - echo `ps aux| grep BrowserStackLocal`; - echo `lsof -i:45691`; - echo $this->pid; - while($this->isRunning()) sleep(1); } } public function command() { - $command = "exec $this->binary_path -logFile $this->logfile $this->folder_flag $this->key $this->folder_path $this->force_local_flag $this->local_identifier_flag $this->only_flag $this->only_automate_flag $this->proxy_host $this->proxy_port $this->proxy_user $this->proxy_pass $this->force_flag $this->verbose_flag $this->hosts"; + $exec = "exec"; + // TODO to test on windows + if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN') + $exec = "call"; + + $command = "$exec $this->binary_path -logFile $this->logfile $this->folder_flag $this->key $this->folder_path $this->force_local_flag $this->local_identifier_flag $this->only_flag $this->only_automate_flag $this->proxy_host $this->proxy_port $this->proxy_user $this->proxy_pass $this->force_flag $this->verbose_flag $this->hosts"; $command = preg_replace('/\s+/S', " ", $command); return $command; }