Skip to content

Commit 3bc2bfe

Browse files
committed
start stop working
1 parent 0abc405 commit 3bc2bfe

File tree

1 file changed

+6
-22
lines changed

1 file changed

+6
-22
lines changed

lib/Local.php

Lines changed: 6 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ class Local {
1616
public $pid = NULL;
1717

1818
public function __construct() {
19-
$this->key = getenv("BROWSERSTACK_ACCESS_KEY");
19+
$this->key = getenv("BROWSERSTACK_KEY");
2020
$this->logfile = getcwd() . "/local.log";
2121
$this->user_args = array();
2222
}
@@ -94,31 +94,15 @@ public function start($arguments) {
9494
$this->binary = new LocalBinary();
9595
$this->binary_path = $this->binary->binary_path();
9696

97-
$descriptorspec = array(
98-
0 => array("pipe", "r"),
99-
1 => array("pipe", "w"),
100-
2 => array("pipe", "w")
101-
);
102-
10397
$call = $this->start_command();
10498
if(strtoupper(substr(PHP_OS, 0, 3)) === 'WIN')
10599
system('echo "" > '. '$this->logfile');
106100
else
107101
system("echo \"\" > '$this->logfile' ");
108-
109-
$this->handle = proc_open($call, $descriptorspec, $this->pipes);
110-
$return_message = "";
111-
while(!feof($this->pipes[1]))
112-
{
113-
$return_message = $return_message + fgets($pipes[1], 1024);
114-
if (strlen($return_message) == 0) break;
115-
ob_flush();
116-
flush();
117-
}
118-
119-
fclose($this->pipes[1]);
120-
$data = json_encode($return_message);
121-
if ($data['state'] != "connected") {
102+
$call = $call . "2>&1";
103+
$return_message = shell_exec($call);
104+
$data = json_decode($return_message,true);
105+
if ($data["state"] != "connected") {
122106
throw new LocalException($data['message']);
123107
}
124108
$this->pid = $data['pid'];
@@ -127,7 +111,7 @@ public function start($arguments) {
127111
public function stop() {
128112
fclose($this->loghandle);
129113
$call = $this->stop_command();
130-
system("$call");
114+
shell_exec("$call");
131115
}
132116

133117
public function start_command() {

0 commit comments

Comments
 (0)