19
19
use \PatternLab \Console \ProcessSpawnerEvent ;
20
20
use \PatternLab \Dispatcher ;
21
21
use \PatternLab \Timer ;
22
+ use \Symfony \Component \Process \Exception \ProcessTimedOutException ;
22
23
use \Symfony \Component \Process \Process ;
23
24
25
+
24
26
class ProcessSpawner {
25
27
26
28
protected $ pluginProcesses ;
@@ -63,13 +65,9 @@ public function spawn($commands = array(), $quiet = false) {
63
65
// if there are processes to spawn do so
64
66
if (!empty ($ processes )) {
65
67
66
- // get the time out
67
- $ timeout = Config::getOption ("timeout " ) ? (int )Config::getOption ("timeout " ) : 3600 ;
68
-
69
68
// start the processes
70
69
foreach ($ processes as $ process ) {
71
70
$ process ["process " ]->start ();
72
- $ process ["process " ]->setTimeout ($ timeout );
73
71
}
74
72
75
73
// check on them and produce output
@@ -83,8 +81,12 @@ public function spawn($commands = array(), $quiet = false) {
83
81
print $ process ["process " ]->getIncrementalErrorOutput ();
84
82
}
85
83
}
86
- } catch (\RuntimeException $ e ) {
87
- Console::writeError ("pattern lab processes automatically time out after " .$ timeout ." seconds... " );
84
+ } catch (ProcessTimedOutException $ e ) {
85
+ if ($ e ->isGeneralTimeout ()) {
86
+ Console::writeError ("pattern lab processes should never time out. yours did... " );
87
+ } else if ($ e ->isIdleTimeout ()) {
88
+ Console::writeError ("pattern lab processes automatically time out if their is no command line output in 30 minutes... " );
89
+ }
88
90
}
89
91
}
90
92
usleep (100000 );
@@ -110,7 +112,7 @@ protected function buildProcess($commandOptions) {
110
112
$ cwd = isset ($ commandOptions ["cwd " ]) ? $ commandOptions ["cwd " ] : null ;
111
113
$ env = isset ($ commandOptions ["env " ]) ? $ commandOptions ["env " ] : null ;
112
114
$ input = isset ($ commandOptions ["input " ]) ? $ commandOptions ["input " ] : null ;
113
- $ timeout = isset ($ commandOptions ["timeout " ]) ? $ commandOptions ["timeout " ] : 60 ;
115
+ $ timeout = isset ($ commandOptions ["timeout " ]) ? $ commandOptions ["timeout " ] : null ;
114
116
$ options = isset ($ commandOptions ["options " ]) ? $ commandOptions ["options " ] : array ();
115
117
$ idle = isset ($ commandOptions ["idle " ]) ? $ commandOptions ["idle " ] : null ;
116
118
$ output = isset ($ commandOptions ["output " ]) ? $ commandOptions ["output " ] : true ;
0 commit comments