MediaWiki master
|
Manage forking inside CLI maintenance scripts. More...
Inherited by MediaWiki\Composer\ComposerLaunchParallel, and MediaWiki\Maintenance\OrderedStreamingForkController.
Public Member Functions | |
__construct ( $numProcs, $flags=0) | |
allSuccessful () | |
Return true if all completed child processes exited with an exit status / return code of 0. | |
getChildNumber () | |
Get the number of the child currently running. | |
start () | |
Start the child processes. | |
Protected Member Functions | |
forkWorkers ( $numProcs) | |
Fork a number of worker processes. | |
handleTermSignal ( $signal) | |
initChild () | |
prepareEnvironment () | |
Protected Attributes | |
int | $childNumber = 0 |
array null | $children = [] |
int[] | $exitStatuses = [] |
int | $flags = 0 |
int | $procsToStart = 0 |
bool | $termReceived = false |
Static Protected Attributes | |
static | $RESTARTABLE_SIGNALS = [] |
Manage forking inside CLI maintenance scripts.
Only handles forking and process control. In the future, this could be extended to provide IPC and job dispatch.
This class requires the posix and pcntl extensions.
Definition at line 37 of file ForkController.php.
MediaWiki\Maintenance\ForkController::__construct | ( | $numProcs, | |
$flags = 0 ) |
int | $numProcs | The number of worker processes to fork |
int | $flags |
Definition at line 68 of file ForkController.php.
References MediaWiki\Maintenance\ForkController\$flags, and wfIsCLI().
MediaWiki\Maintenance\ForkController::allSuccessful | ( | ) |
Return true if all completed child processes exited with an exit status / return code of 0.
Definition at line 182 of file ForkController.php.
|
protected |
Fork a number of worker processes.
int | $numProcs |
Reimplemented in MediaWiki\Maintenance\OrderedStreamingForkController.
Definition at line 213 of file ForkController.php.
Referenced by MediaWiki\Maintenance\ForkController\start().
MediaWiki\Maintenance\ForkController::getChildNumber | ( | ) |
Get the number of the child currently running.
Note, this is not the pid, but rather which of the total number of children we are
Definition at line 196 of file ForkController.php.
|
protected |
Definition at line 243 of file ForkController.php.
|
protected |
Definition at line 238 of file ForkController.php.
Referenced by MediaWiki\Maintenance\OrderedStreamingForkController\forkWorkers().
|
protected |
Reimplemented in MediaWiki\Composer\ComposerLaunchParallel.
Definition at line 200 of file ForkController.php.
References MediaWiki\MediaWikiServices\getInstance(), and MediaWiki\MediaWikiServices\resetChildProcessServices().
Referenced by MediaWiki\Maintenance\OrderedStreamingForkController\forkWorkers().
MediaWiki\Maintenance\ForkController::start | ( | ) |
Start the child processes.
This should only be called from the command line. It should be called as early as possible during execution.
This will return 'child' in the child processes. In the parent process, it will run until all the child processes exit or a TERM signal is received. It will then return 'done'.
Reimplemented in MediaWiki\Composer\ComposerLaunchParallel, and MediaWiki\Maintenance\OrderedStreamingForkController.
Definition at line 102 of file ForkController.php.
References MediaWiki\Maintenance\ForkController\forkWorkers().
|
protected |
Definition at line 42 of file ForkController.php.
|
protected |
Definition at line 39 of file ForkController.php.
|
protected |
Definition at line 56 of file ForkController.php.
|
protected |
Definition at line 48 of file ForkController.php.
Referenced by MediaWiki\Maintenance\ForkController\__construct().
|
protected |
Definition at line 51 of file ForkController.php.
|
staticprotected |
Definition at line 53 of file ForkController.php.
|
protected |
Definition at line 45 of file ForkController.php.