PHP Класс PHPPM\ProcessManager

Показать файл Открыть проект Примеры использования класса

Защищенные свойства (Protected)

Свойство Тип Описание
$appBootstrap string
$appenv string | null
$bridge string
$concurrentRequestsPerWorker boolean This can lead to issues when the application does not support it (like when they operate on globals at the same time)
$controller PHPPM\React\Server
$controllerHost string
$debug boolean
$emergencyMode boolean Whether we are in the emergency mode or not. True means we need to close all workers due a fatal error and waiting for file changes to be able to restart workers.
$filesLastMTime
$filesLastMd5
$filesToTrack
$handledRequests integer Counter of handled clients.
$host string
$inReload boolean Whether the server is in the reload phase.
$inShutdown boolean
$index integer
$isRunning boolean Whether the server is up and thus creates new slaves when they die or not.
$lastWorkerErrorPrintBy null | integer
$logging boolean
$loop React\EventLoop\LibEventLoop | React\EventLoop\StreamSelectLoop
$maxRequests integer How many requests each worker is allowed to handle until it will be restarted.
$output Symfony\Component\Console\Output\OutputInterface
$phpCgiExecutable string Full path to the php-cgi executable. If not set, we try to determine the path automatically.
$port integer
$ports string[] $object_hash => port
$servingStatic boolean
$slaveCount integer
$slaves array
$tcpConnector React\SocketClient\TcpConnector
$timeout integer Timeout in seconds for master to worker connection.
$waitForSlaves boolean
$web React\Socket\Server

Открытые методы

Метод Описание
__construct ( Symfony\Component\Console\Output\OutputInterface $output, integer $port = 8080, string $host = '127.0.0.1', integer $slaveCount = 8 ) ProcessManager constructor.
getAppBootstrap ( ) : string
getAppEnv ( ) : string
getBridge ( ) : string
handleSigchld ( ) Handling zombie processes on SIGCHLD
isDebug ( ) : boolean
isLogging ( ) : boolean
isServingStatic ( ) : boolean
onSlaveConnection ( Connection $conn ) Handles data communication from slave -> master
onWeb ( Connection $incoming ) Handles incoming connections from $this->port. Basically redirects to a slave.
restartWorker ( ) Closes all slaves, so we automatically reconnect. Necessary when watched files have changed.
run ( ) Starts the main loop. Blocks.
setAppBootstrap ( string $appBootstrap )
setAppEnv ( string | null $appenv )
setBridge ( string $bridge )
setConcurrentRequestsPerWorker ( boolean $concurrentRequestsPerWorker )
setDebug ( boolean $debug )
setLogging ( boolean $logging )
setMaxRequests ( integer $maxRequests )
setPhpCgiExecutable ( string $phpCgiExecutable )
setServingStatic ( boolean $servingStatic )
shutdown ( ) Handles termination signals, so we can gracefully stop all servers.

Защищенные методы

Метод Описание
bootstrapFailed ( Connection $conn ) Handles failed application bootstraps.
checkChangedFiles ( boolean $restartWorkers = true ) : boolean Checks if tracked files have changed. If so, restart all slaves.
commandFiles ( array $data, Connection $conn )
commandLog ( array $data, Connection $conn ) Prints logs.
commandReady ( array $data, Connection $conn ) A slave sent a ready commands which basically says that the slave bootstrapped successfully the application and is ready to accept connections.
commandRegister ( array $data, Connection $conn ) A slave sent a register command.
commandStatus ( array $data, Connection $conn ) A slave sent a status command.
getNextSlave ( $cb ) : integer Returns the next free slave. This method is async, so be aware of async calls between this call.
getPort ( Connection $conn ) : null | integer
isConnectionRegistered ( Connection $conn ) : boolean Whether the given connection is registered.
isHeaderEnd ( string $buffer ) : boolean Checks whether the end of the header is in $buffer.
newInstance ( integer $port ) Creates a new ProcessSlave instance.
replaceHeader ( string $header, string[] $headersToReplace ) : string Replaces or injects header

Описание методов

__construct() публичный Метод

ProcessManager constructor.
public __construct ( Symfony\Component\Console\Output\OutputInterface $output, integer $port = 8080, string $host = '127.0.0.1', integer $slaveCount = 8 )
$output Symfony\Component\Console\Output\OutputInterface
$port integer
$host string
$slaveCount integer

bootstrapFailed() защищенный Метод

Handles failed application bootstraps.
protected bootstrapFailed ( Connection $conn )
$conn React\Socket\Connection

checkChangedFiles() защищенный Метод

This approach uses simple filemtime to check against modifications. It is using this technique because all other file watching stuff have either big dependencies or do not work under all platforms without installing a pecl extension. Also this way is interestingly fast and is only used when debug=true.
protected checkChangedFiles ( boolean $restartWorkers = true ) : boolean
$restartWorkers boolean
Результат boolean

commandFiles() защищенный Метод

protected commandFiles ( array $data, Connection $conn )
$data array
$conn React\Socket\Connection

commandLog() защищенный Метод

Prints logs.
protected commandLog ( array $data, Connection $conn )
$data array
$conn React\Socket\Connection

commandReady() защищенный Метод

A slave sent a ready commands which basically says that the slave bootstrapped successfully the application and is ready to accept connections.
protected commandReady ( array $data, Connection $conn )
$data array
$conn React\Socket\Connection

commandRegister() защищенный Метод

A slave sent a register command.
protected commandRegister ( array $data, Connection $conn )
$data array
$conn React\Socket\Connection

commandStatus() защищенный Метод

A slave sent a status command.
protected commandStatus ( array $data, Connection $conn )
$data array
$conn React\Socket\Connection

getAppBootstrap() публичный Метод

public getAppBootstrap ( ) : string
Результат string

getAppEnv() публичный Метод

public getAppEnv ( ) : string
Результат string

getBridge() публичный Метод

public getBridge ( ) : string
Результат string

getNextSlave() защищенный Метод

Returns the next free slave. This method is async, so be aware of async calls between this call.
protected getNextSlave ( $cb ) : integer
Результат integer

getPort() защищенный Метод

protected getPort ( Connection $conn ) : null | integer
$conn React\Socket\Connection
Результат null | integer

handleSigchld() публичный Метод

Handling zombie processes on SIGCHLD
public handleSigchld ( )

isConnectionRegistered() защищенный Метод

Whether the given connection is registered.
protected isConnectionRegistered ( Connection $conn ) : boolean
$conn React\Socket\Connection
Результат boolean

isDebug() публичный Метод

public isDebug ( ) : boolean
Результат boolean

isHeaderEnd() защищенный Метод

Checks whether the end of the header is in $buffer.
protected isHeaderEnd ( string $buffer ) : boolean
$buffer string
Результат boolean

isLogging() публичный Метод

public isLogging ( ) : boolean
Результат boolean

isServingStatic() публичный Метод

public isServingStatic ( ) : boolean
Результат boolean

newInstance() защищенный Метод

Creates a new ProcessSlave instance.
protected newInstance ( integer $port )
$port integer

onSlaveConnection() публичный Метод

Handles data communication from slave -> master
public onSlaveConnection ( Connection $conn )
$conn React\Socket\Connection

onWeb() публичный Метод

Handles incoming connections from $this->port. Basically redirects to a slave.
public onWeb ( Connection $incoming )
$incoming React\Socket\Connection incoming connection from react

replaceHeader() защищенный Метод

Replaces or injects header
protected replaceHeader ( string $header, string[] $headersToReplace ) : string
$header string
$headersToReplace string[]
Результат string

restartWorker() публичный Метод

Closes all slaves, so we automatically reconnect. Necessary when watched files have changed.
public restartWorker ( )

run() публичный Метод

Starts the main loop. Blocks.
public run ( )

setAppBootstrap() публичный Метод

public setAppBootstrap ( string $appBootstrap )
$appBootstrap string

setAppEnv() публичный Метод

public setAppEnv ( string | null $appenv )
$appenv string | null

setBridge() публичный Метод

public setBridge ( string $bridge )
$bridge string

setConcurrentRequestsPerWorker() публичный Метод

public setConcurrentRequestsPerWorker ( boolean $concurrentRequestsPerWorker )
$concurrentRequestsPerWorker boolean

setDebug() публичный Метод

public setDebug ( boolean $debug )
$debug boolean

setLogging() публичный Метод

public setLogging ( boolean $logging )
$logging boolean

setMaxRequests() публичный Метод

public setMaxRequests ( integer $maxRequests )
$maxRequests integer

setPhpCgiExecutable() публичный Метод

public setPhpCgiExecutable ( string $phpCgiExecutable )
$phpCgiExecutable string

setServingStatic() публичный Метод

public setServingStatic ( boolean $servingStatic )
$servingStatic boolean

shutdown() публичный Метод

Handles termination signals, so we can gracefully stop all servers.
public shutdown ( )

Описание свойств

$appBootstrap защищенное свойство

protected string $appBootstrap
Результат string

$appenv защищенное свойство

protected string|null $appenv
Результат string | null

$bridge защищенное свойство

protected string $bridge
Результат string

$concurrentRequestsPerWorker защищенное свойство

This can lead to issues when the application does not support it (like when they operate on globals at the same time)
protected bool $concurrentRequestsPerWorker
Результат boolean

$controller защищенное свойство

protected Server,PHPPM\React $controller
Результат PHPPM\React\Server

$controllerHost защищенное свойство

protected string $controllerHost
Результат string

$debug защищенное свойство

protected bool $debug
Результат boolean

$emergencyMode защищенное свойство

Whether we are in the emergency mode or not. True means we need to close all workers due a fatal error and waiting for file changes to be able to restart workers.
protected bool $emergencyMode
Результат boolean

$filesLastMTime защищенное свойство

protected $filesLastMTime

$filesLastMd5 защищенное свойство

protected $filesLastMd5

$filesToTrack защищенное свойство

protected $filesToTrack

$handledRequests защищенное свойство

Counter of handled clients.
protected int $handledRequests
Результат integer

$host защищенное свойство

protected string $host
Результат string

$inReload защищенное свойство

Whether the server is in the reload phase.
protected bool $inReload
Результат boolean

$inShutdown защищенное свойство

protected bool $inShutdown
Результат boolean

$index защищенное свойство

protected int $index
Результат integer

$isRunning защищенное свойство

Whether the server is up and thus creates new slaves when they die or not.
protected bool $isRunning
Результат boolean

$lastWorkerErrorPrintBy защищенное свойство

protected null|int $lastWorkerErrorPrintBy
Результат null | integer

$logging защищенное свойство

protected bool $logging
Результат boolean

$loop защищенное свойство

protected LibEventLoop,React\EventLoop|StreamSelectLoop,React\EventLoop $loop
Результат React\EventLoop\LibEventLoop | React\EventLoop\StreamSelectLoop

$maxRequests защищенное свойство

How many requests each worker is allowed to handle until it will be restarted.
protected int $maxRequests
Результат integer

$output защищенное свойство

protected OutputInterface,Symfony\Component\Console\Output $output
Результат Symfony\Component\Console\Output\OutputInterface

$phpCgiExecutable защищенное свойство

Full path to the php-cgi executable. If not set, we try to determine the path automatically.
protected string $phpCgiExecutable
Результат string

$port защищенное свойство

protected int $port
Результат integer

$ports защищенное свойство

$object_hash => port
protected string[] $ports
Результат string[]

$servingStatic защищенное свойство

protected bool $servingStatic
Результат boolean

$slaveCount защищенное свойство

protected int $slaveCount
Результат integer

$slaves защищенное свойство

protected array $slaves
Результат array

$tcpConnector защищенное свойство

protected TcpConnector,React\SocketClient $tcpConnector
Результат React\SocketClient\TcpConnector

$timeout защищенное свойство

Timeout in seconds for master to worker connection.
protected int $timeout
Результат integer

$waitForSlaves защищенное свойство

protected bool $waitForSlaves
Результат boolean

$web защищенное свойство

protected Server,React\Socket $web
Результат React\Socket\Server