MediaWiki
1.28.0
|
Class for managing forking command line scripts. More...
Public Member Functions | |
__construct ($numProcs, $flags=0) | |
getChildNumber () | |
Get the number of the child currently running. More... | |
start () | |
Start the child processes. More... | |
Public Attributes | |
$childNumber = 0 | |
$procsToStart = 0 | |
const | RESTART_ON_ERROR = 1 |
Pass this flag to __construct() to cause the class to automatically restart workers that exit with non-zero exit status or a signal such as SIGSEGV. More... | |
Protected Member Functions | |
forkWorkers ($numProcs) | |
Fork a number of worker processes. More... | |
handleTermSignal ($signal) | |
initChild () | |
prepareEnvironment () | |
Protected Attributes | |
$children = [] | |
$flags = 0 | |
$termReceived = false | |
Static Protected Attributes | |
static | $restartableSignals |
Class for managing forking command line scripts.
Currently just does forking and process control, but it could easily be extended to provide IPC and job dispatch.
This class requires the posix and pcntl extensions.
Definition at line 33 of file ForkController.php.
ForkController::__construct | ( | $numProcs, | |
$flags = 0 |
|||
) |
Definition at line 56 of file ForkController.php.
|
protected |
Fork a number of worker processes.
int | $numProcs |
Definition at line 169 of file ForkController.php.
References initChild(), and prepareEnvironment().
Referenced by start().
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 147 of file ForkController.php.
References $childNumber.
|
protected |
Definition at line 201 of file ForkController.php.
|
protected |
Definition at line 194 of file ForkController.php.
References $wgMemc, global, and wfGetCache().
Referenced by forkWorkers().
|
protected |
Definition at line 151 of file ForkController.php.
References $wgMemc, ObjectCache\clear(), FileBackendGroup\destroySingleton(), LockManagerGroup\destroySingletons(), JobQueueGroup\destroySingletons(), RedisConnectionPool\destroySingletons(), and global.
Referenced by forkWorkers().
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'.
Definition at line 75 of file ForkController.php.
References $status, as, flags, and forkWorkers().
ForkController::$childNumber = 0 |
Definition at line 34 of file ForkController.php.
Referenced by getChildNumber().
|
protected |
Definition at line 34 of file ForkController.php.
|
protected |
Definition at line 36 of file ForkController.php.
Referenced by __construct().
ForkController::$procsToStart = 0 |
Definition at line 36 of file ForkController.php.
|
staticprotected |
Definition at line 38 of file ForkController.php.
|
protected |
Definition at line 35 of file ForkController.php.
const ForkController::RESTART_ON_ERROR = 1 |
Pass this flag to __construct() to cause the class to automatically restart workers that exit with non-zero exit status or a signal such as SIGSEGV.
Definition at line 54 of file ForkController.php.