PHP Class Ko\ProcessManager

Author: Nikolay Bondarenko ([email protected])
Inheritance: implements Countable, use trait Ko\Mixin\ProcessTitle, use trait Ko\Mixin\EventEmitter
ファイルを表示 Open project: misterion/ko-process Class Usage Examples

Protected Properties

Property Type Description
$children ko\Process[]
$sigTerm boolean
$signalHandler ko\SignalHandler
$spawnWatch ko\Process[]

Public Methods

Method Description
__construct ( )
count ( ) : integer Return count of currently running child process.
demonize ( ) Forks the currently running process to detach from console.
dispatch ( ) Calls signal handlers for pending signals.
dispatchSignals ( ) Calls signal handlers for pending signals.
fork ( callable $callable ) : ko\Process Forks the currently running process.
getProcessCount ( ) : integer Return count of currently running child process.
handleSigChild ( )
handleSigTerm ( )
hasAlive ( ) : boolean Return TRUE is manager has alive children processes.
onShutdown ( callable $callable ) Master process shutdown handler. Shutdown handler called right after the SIGTERM catches by this class.
spawn ( callable $callable ) : ko\Process
wait ( ) Suspends execution of the current process until all children has exited, or until a signal is delivered whose action is to terminate the current process.

Protected Methods

Method Description
childProcessDie ( $pid, $status )
createProcess ( callable $callable )
internalEmit ( )
internalFork ( ko\Process $p ) : ko\Process
internalOn ( )
internalSpawn ( ko\Process $p )
setupSignalHandlers ( )

Method Details

__construct() public method

public __construct ( )

childProcessDie() protected method

protected childProcessDie ( $pid, $status )

count() public method

Return count of currently running child process.
public count ( ) : integer
return integer

createProcess() protected method

protected createProcess ( callable $callable )
$callable callable

demonize() public method

Forks the currently running process to detach from console.
public demonize ( )

dispatch() public method

Calls signal handlers for pending signals.
public dispatch ( )

dispatchSignals() public method

Calls signal handlers for pending signals.
Deprecation: Use ProcessManager::dispatch()
public dispatchSignals ( )

fork() public method

Forks the currently running process.
public fork ( callable $callable ) : ko\Process
$callable callable Callable with prototype like function(Ko\Process $p) }
return ko\Process

getProcessCount() public method

Return count of currently running child process.
public getProcessCount ( ) : integer
return integer

handleSigChild() public method

public handleSigChild ( )

handleSigTerm() public method

public handleSigTerm ( )

hasAlive() public method

Return TRUE is manager has alive children processes.
public hasAlive ( ) : boolean
return boolean

internalEmit() protected method

protected internalEmit ( )

internalFork() protected method

protected internalFork ( ko\Process $p ) : ko\Process
$p ko\Process
return ko\Process

internalOn() protected method

protected internalOn ( )

internalSpawn() protected method

protected internalSpawn ( ko\Process $p )
$p ko\Process

onShutdown() public method

Master process shutdown handler. Shutdown handler called right after the SIGTERM catches by this class.
public onShutdown ( callable $callable )
$callable callable

setupSignalHandlers() protected method

protected setupSignalHandlers ( )

spawn() public method

public spawn ( callable $callable ) : ko\Process
$callable callable Callable with prototype like function(Ko\Process $p) }
return ko\Process

wait() public method

Suspends execution of the current process until all children has exited, or until a signal is delivered whose action is to terminate the current process.
public wait ( )

Property Details

$children protected_oe property

protected Process[],ko $children
return ko\Process[]

$sigTerm protected_oe property

protected bool $sigTerm
return boolean

$signalHandler protected_oe property

protected SignalHandler,ko $signalHandler
return ko\SignalHandler

$spawnWatch protected_oe property

protected Process[],ko $spawnWatch
return ko\Process[]