PHP 클래스 PHPPM\ProcessManager

파일 보기 프로젝트 열기: php-pm/php-pm 1 사용 예제들

보호된 프로퍼티들

프로퍼티 타입 설명
$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