File tree 1 file changed +22
-7
lines changed
1 file changed +22
-7
lines changed Original file line number Diff line number Diff line change 27
27
$ magentoBinary = $ php . ' -f ../../../../bin/magento ' ;
28
28
$ valid = validateCommand ($ magentoBinary , $ command );
29
29
if ($ valid ) {
30
- exec (
31
- escapeCommand ($ magentoBinary . " $ command " . " $ arguments " ) . " 2>&1 " ,
32
- $ output ,
33
- $ exitCode
34
- );
35
- if ($ exitCode == 0 ) {
30
+ $ process = new Symfony \Component \Process \Process ($ magentoBinary . " $ command " . " $ arguments " );
31
+ $ process ->setIdleTimeout (60 );
32
+ $ process ->setTimeout (0 );
33
+ $ idleTimeout = false ;
34
+ try {
35
+ $ process ->run ();
36
+ $ output = $ process ->getOutput ();
37
+ if (!$ process ->isSuccessful ()) {
38
+ $ output = $ process ->getErrorOutput ();
39
+ }
40
+ if (empty ($ output )) {
41
+ $ output = "CLI did not return output. " ;
42
+ }
43
+
44
+ } catch (Symfony \Component \Process \Exception \ProcessTimedOutException $ exception ) {
45
+ $ output = "CLI command timed out, no output available. " ;
46
+ $ idleTimeout = true ;
47
+ }
48
+ $ exitCode = $ process ->getExitCode ();
49
+
50
+ if ($ exitCode == 0 || $ idleTimeout ) {
36
51
http_response_code (202 );
37
52
} else {
38
53
http_response_code (500 );
39
54
}
40
- echo implode ( "\n" , $ output) ;
55
+ echo $ output ;
41
56
} else {
42
57
http_response_code (403 );
43
58
echo "Given command not found valid in Magento CLI Command list. " ;
You can’t perform that action at this time.
0 commit comments