ForkController Class Reference

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

List of all members.

Public Member Functions

 __construct ($numProcs, $flags=0)
 start ()
 Start the child processes.

Public Attributes

 $children = array()
 $termReceived = false
 $flags = 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.

Static Public Attributes

static $restartableSignals

Protected Member Functions

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


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


Constructor & Destructor Documentation

ForkController::__construct ( numProcs,
flags = 0 
)

Definition at line 33 of file ForkController.php.

References $flags.


Member Function Documentation

ForkController::forkWorkers ( numProcs  )  [protected]

Fork a number of worker processes.

Definition at line 124 of file ForkController.php.

References $i, $wgCaches, $wgMainCacheType, $wgMemc, initChild(), and prepareEnvironment().

Referenced by start().

ForkController::handleTermSignal ( signal  )  [protected]

Definition at line 157 of file ForkController.php.

ForkController::initChild (  )  [protected]

Definition at line 150 of file ForkController.php.

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

Referenced by forkWorkers().

ForkController::prepareEnvironment (  )  [protected]

Definition at line 113 of file ForkController.php.

References $wgCaches, $wgMemc, and wfGetLBFactory().

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

References $status, and forkWorkers().


Member Data Documentation

ForkController::$children = array()

Definition at line 11 of file ForkController.php.

ForkController::$flags = 0

Definition at line 13 of file ForkController.php.

Referenced by __construct().

ForkController::$procsToStart = 0

Definition at line 13 of file ForkController.php.

ForkController::$restartableSignals [static]

Initial value:

 array(
                SIGFPE,
                SIGILL,
                SIGSEGV,
                SIGBUS,
                SIGABRT,
                SIGSYS,
                SIGPIPE,
                SIGXCPU,
                SIGXFSZ,
        )

Definition at line 15 of file ForkController.php.

ForkController::$termReceived = false

Definition at line 12 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 31 of file ForkController.php.


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

Generated on Sat Sep 5 02:08:38 2009 for MediaWiki by  doxygen 1.5.9