diff options
Diffstat (limited to 'MLEB/Translate/scripts/ttmserver-export.php')
-rw-r--r-- | MLEB/Translate/scripts/ttmserver-export.php | 33 |
1 files changed, 27 insertions, 6 deletions
diff --git a/MLEB/Translate/scripts/ttmserver-export.php b/MLEB/Translate/scripts/ttmserver-export.php index 05c20298..7b331cc4 100644 --- a/MLEB/Translate/scripts/ttmserver-export.php +++ b/MLEB/Translate/scripts/ttmserver-export.php @@ -21,9 +21,7 @@ require_once "$IP/maintenance/Maintenance.php"; * @since 2012-01-26 */ class TTMServerBootstrap extends Maintenance { - /** - * @var int - */ + /** @var int */ private $start; public function __construct() { @@ -48,7 +46,7 @@ class TTMServerBootstrap extends Maintenance { ); $this->addOption( 'dry-run', - 'Do not make any actualy changes in the index.' + 'Do not make any changes to the index.' ); $this->addOption( 'verbose', @@ -102,11 +100,12 @@ class TTMServerBootstrap extends Maintenance { $status = 0; pcntl_waitpid( $pid, $status ); // beginBootstrap probably failed, give up. - if ( $status !== 0 ) { - $this->fatalError( 'Boostrap failed.' ); + if ( !$this->verifyChildStatus( $pid, $status ) ) { + $this->fatalError( 'Bootstrap failed.' ); } } + $hasErrors = false; $threads = $this->getOption( 'threads', 1 ); $pids = []; @@ -137,6 +136,7 @@ class TTMServerBootstrap extends Maintenance { if ( count( $pids ) >= $threads ) { $status = 0; $pid = pcntl_wait( $status ); + $hasErrors = $hasErrors || !$this->verifyChildStatus( $pid, $status ); unset( $pids[$pid] ); } } @@ -146,10 +146,15 @@ class TTMServerBootstrap extends Maintenance { foreach ( array_keys( $pids ) as $pid ) { $status = 0; pcntl_waitpid( $pid, $status ); + $hasErrors = $hasErrors || !$this->verifyChildStatus( $pid, $status ); } // It's okay to do this in the main thread as it is the last thing $this->endBootstrap( $server ); + + if ( $hasErrors ) { + $this->fatalError( '!!! Some threads failed. Review the script output !!!' ); + } } private function getServer( array $config ): WritableTTMServer { @@ -283,6 +288,22 @@ class TTMServerBootstrap extends Maintenance { // we can't use them in forked children. MediaWiki\MediaWikiServices::resetChildProcessServices(); } + + private function verifyChildStatus( int $pid, int $status ): bool { + if ( pcntl_wifexited( $status ) ) { + $code = pcntl_wexitstatus( $status ); + if ( $code ) { + $this->output( "Pid $pid exited with status $code !!\n" ); + return false; + } + } elseif ( pcntl_wifsignaled( $status ) ) { + $signum = pcntl_wtermsig( $status ); + $this->output( "Pid $pid terminated by signal $signum !!\n" ); + return false; + } + + return true; + } } $maintClass = TTMServerBootstrap::class; |