@@ -161,19 +161,32 @@ public function getPackages()
161
161
public function process ()
162
162
{
163
163
$ returnStatus = 0 ;
164
+ $ logDelay = 10 ;
164
165
$ this ->start = $ this ->lastJobStarted = time ();
165
166
$ packages = $ this ->packages ;
166
167
while (count ($ packages ) && $ this ->checkTimeout ()) {
167
168
foreach ($ packages as $ name => $ packageJob ) {
168
169
// Unsets each member of $packages array (passed by reference) as each is executed
169
170
$ this ->assertAndExecute ($ name , $ packages , $ packageJob );
170
171
}
171
- $ this ->logger ->info ('. ' );
172
- // phpcs:ignore Magento2.Functions.DiscouragedFunction
173
- sleep (3 );
174
- foreach ($ this ->inProgress as $ name => $ package ) {
175
- if ($ this ->isDeployed ($ package )) {
176
- unset($ this ->inProgress [$ name ]);
172
+
173
+ // refresh current status in console once in 10 iterations (once in 5 sec)
174
+ if ($ logDelay >= 10 ) {
175
+ $ this ->logger ->info ('. ' );
176
+ $ logDelay = 0 ;
177
+ } else {
178
+ $ logDelay ++;
179
+ }
180
+
181
+ if ($ this ->isCanBeParalleled ()) {
182
+ // in parallel mode sleep before trying to check status and run new jobs
183
+ // phpcs:ignore Magento2.Functions.DiscouragedFunction
184
+ usleep (500000 ); // 0.5 sec (less sleep == less time waste)
185
+
186
+ foreach ($ this ->inProgress as $ name => $ package ) {
187
+ if ($ this ->isDeployed ($ package )) {
188
+ unset($ this ->inProgress [$ name ]);
189
+ }
177
190
}
178
191
}
179
192
}
@@ -243,15 +256,25 @@ private function executePackage(Package $package, string $name, array &$packages
243
256
*/
244
257
private function awaitForAllProcesses ()
245
258
{
259
+ $ logDelay = 10 ;
246
260
while ($ this ->inProgress && $ this ->checkTimeout ()) {
247
261
foreach ($ this ->inProgress as $ name => $ package ) {
248
262
if ($ this ->isDeployed ($ package )) {
249
263
unset($ this ->inProgress [$ name ]);
250
264
}
251
265
}
252
- $ this ->logger ->info ('. ' );
266
+
267
+ // refresh current status in console once in 10 iterations (once in 5 sec)
268
+ if ($ logDelay >= 10 ) {
269
+ $ this ->logger ->info ('. ' );
270
+ $ logDelay = 0 ;
271
+ } else {
272
+ $ logDelay ++;
273
+ }
274
+
275
+ // sleep before checking parallel jobs status
253
276
// phpcs:ignore Magento2.Functions.DiscouragedFunction
254
- sleep ( 5 );
277
+ usleep ( 500000 ); // 0.5 sec (less sleep == less time waste)
255
278
}
256
279
if ($ this ->isCanBeParalleled ()) {
257
280
// close connections only if ran with forks
0 commit comments