MediaWiki  REL1_24
ForkController Class Reference

Class for managing forking command line scripts. More...

List of all members.

Public Member Functions

 __construct ($numProcs, $flags=0)
 getChildNumber ()
 Get the number of the child currently running.
 start ()
 Start the child processes.

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.

Protected Member Functions

 forkWorkers ($numProcs)
 Fork a number of worker processes.
 handleTermSignal ($signal)
 initChild ()
 prepareEnvironment ()

Protected Attributes

 $children = array()
 $flags = 0
 $termReceived = false

Static Protected Attributes

static $restartableSignals

Detailed Description

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 32 of file ForkController.php.


Constructor & Destructor Documentation

ForkController::__construct ( numProcs,
flags = 0 
)

Definition at line 55 of file ForkController.php.

References $flags, and flags.


Member Function Documentation

ForkController::forkWorkers ( numProcs) [protected]

Fork a number of worker processes.

Parameters:
int$numProcs
Returns:
string

Definition at line 166 of file ForkController.php.

References initChild(), and prepareEnvironment().

Referenced by start().

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

Returns:
int

Definition at line 146 of file ForkController.php.

ForkController::handleTermSignal ( signal) [protected]

Definition at line 198 of file ForkController.php.

ForkController::initChild ( ) [protected]

Definition at line 191 of file ForkController.php.

References $wgMainCacheType, $wgMemc, global, and wfGetCache().

Referenced by forkWorkers().

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'.

Returns:
string

Definition at line 74 of file ForkController.php.

References array(), as, flags, and forkWorkers().


Member Data Documentation

ForkController::$childNumber = 0

Definition at line 33 of file ForkController.php.

ForkController::$children = array() [protected]

Definition at line 33 of file ForkController.php.

ForkController::$flags = 0 [protected]

Definition at line 35 of file ForkController.php.

Referenced by __construct().

ForkController::$procsToStart = 0

Definition at line 35 of file ForkController.php.

ForkController::$restartableSignals [static, protected]
Initial value:
 array(
        SIGFPE,
        SIGILL,
        SIGSEGV,
        SIGBUS,
        SIGABRT,
        SIGSYS,
        SIGPIPE,
        SIGXCPU,
        SIGXFSZ,
    )

Definition at line 37 of file ForkController.php.

ForkController::$termReceived = false [protected]

Definition at line 34 of file ForkController.php.

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 53 of file ForkController.php.


The documentation for this class was generated from the following file: