PHP Class PHPDaemon\Thread\Worker

Author: Vasily Zorin ([email protected])
Inheritance: extends Generic
Datei anzeigen Open project: kakserpom/phpdaemon Class Usage Examples

Public Properties

Property Type Description
$IPCManager PHPDaemon\IPCManager\IPCManager
$breakMainLoop boolean Break main loop?
$connection Connection Connection
$counterGC integer Counter GC
$instancesCount array Instances count
$lambdaCache
$reload boolean Reload?
$reloadReady boolean Reload ready?
$reloaded boolean Reloaded?
$reqCounter integer Request counter
$state integer State
$timeLastActivity integer Time of last activity
$update boolean Update?

Protected Properties

Property Type Description
$autoReloadLast integer Last time of auto reload
$delayedSigReg boolean If true, we do not register signals automatically at start
$graceful
$reloadDelay integer Reload delay

Public Methods

Method Description
__destruct ( ) : void Destructor of worker thread.
createFunction ( $args, $body, $ttl = null ) : void Creates anonymous function (old-fashioned) like create_function()
define ( $k, $v )
gracefulRestart ( ) : void Graceful restart
gracefulStop ( ) : void Graceful stop
header ( $args )
headersList ( ) $this->override('headersSent', 'headers_sent); // Commented out due to a runkit bug
headersSent ( &$file = null, &$line = null )
isUploadedFile ( $args )
log ( string $message ) : void Log something
moveUploadedFile ( $args )
onTerminated ( ) : void Called (in master) when process is terminated
registerShutdownFunction ( callable $cb )
setState ( $int ) : boolean Set current status of worker
setcookie ( $args )

Protected Methods

Method Description
appInstancesReloadReady ( ) : boolean Asks the running applications the whether we can go to shutdown current (old) worker.
breakMainLoopCheck ( ) : void Check if we should break main loop
override ( $camelCase, string $real ) Override a standard PHP function
overrideNativeFuncs ( ) : void Overrides native PHP functions.
prepareSystemEnv ( ) : void Setup settings on start.
run ( ) : void Runtime of Worker process.
shutdown ( $hard = false ) : boolean | null Shutdown this worker
sighup ( ) : void Handler of the SIGHUP (reload config) signal in worker process.
sigint ( ) : void Handler of the SIGINT (hard shutdown) signal in worker process.
sigpipe ( ) : void Handler of the SIGPIPE signal in worker process.
sigquit ( ) : void Handler of the SIGQUIT (graceful shutdown) signal in worker process.
sigterm ( ) : void Handler of the SIGTERM (graceful shutdown) signal in worker process.
sigtstp ( ) : void Handler of the SIGTSTP (graceful stop) signal in worker process.
sigttin ( ) : void Handler of the SIGTTIN signal in worker process.
sigunknown ( $signo ) : void Handler of non-known signals.
sigusr1 ( ) : void Handler of the SIGUSR1 (re-open log-file) signal in worker process.
sigusr2 ( ) : void Handler of the SIGUSR2 (graceful shutdown for update) signal in worker process.
update ( ) : void Reloads additional config-files on-the-fly.

Method Details

__destruct() public method

Destructor of worker thread.
public __destruct ( ) : void
return void

appInstancesReloadReady() protected method

Asks the running applications the whether we can go to shutdown current (old) worker.
protected appInstancesReloadReady ( ) : boolean
return boolean - Ready?

breakMainLoopCheck() protected method

Check if we should break main loop
protected breakMainLoopCheck ( ) : void
return void

createFunction() public method

Creates anonymous function (old-fashioned) like create_function()
public createFunction ( $args, $body, $ttl = null ) : void
return void

define() public method

public define ( $k, $v )

gracefulRestart() public method

Graceful restart
public gracefulRestart ( ) : void
return void

gracefulStop() public method

Graceful stop
public gracefulStop ( ) : void
return void

header() public method

public header ( $args )

headersList() public method

$this->override('headersSent', 'headers_sent); // Commented out due to a runkit bug
public headersList ( )

headersSent() public method

public headersSent ( &$file = null, &$line = null )

isUploadedFile() public method

public isUploadedFile ( $args )

log() public method

Log something
public log ( string $message ) : void
$message string
return void

moveUploadedFile() public method

public moveUploadedFile ( $args )

onTerminated() public method

Called (in master) when process is terminated
public onTerminated ( ) : void
return void

override() protected method

Override a standard PHP function
protected override ( $camelCase, string $real )
$real string e.g. is_uploaded_file

overrideNativeFuncs() protected method

Overrides native PHP functions.
protected overrideNativeFuncs ( ) : void
return void

prepareSystemEnv() protected method

Setup settings on start.
protected prepareSystemEnv ( ) : void
return void

registerShutdownFunction() public method

run() protected method

Runtime of Worker process.
protected run ( ) : void
return void

setState() public method

Set current status of worker
public setState ( $int ) : boolean
return boolean Success.

setcookie() public method

public setcookie ( $args )

shutdown() protected method

Shutdown this worker
protected shutdown ( $hard = false ) : boolean | null
return boolean | null Ready?

sighup() protected method

Handler of the SIGHUP (reload config) signal in worker process.
protected sighup ( ) : void
return void

sigint() protected method

Handler of the SIGINT (hard shutdown) signal in worker process.
protected sigint ( ) : void
return void

sigpipe() protected method

Handler of the SIGPIPE signal in worker process.
protected sigpipe ( ) : void
return void

sigquit() protected method

Handler of the SIGQUIT (graceful shutdown) signal in worker process.
protected sigquit ( ) : void
return void

sigterm() protected method

Handler of the SIGTERM (graceful shutdown) signal in worker process.
protected sigterm ( ) : void
return void

sigtstp() protected method

Handler of the SIGTSTP (graceful stop) signal in worker process.
protected sigtstp ( ) : void
return void

sigttin() protected method

Handler of the SIGTTIN signal in worker process.
protected sigttin ( ) : void
return void

sigunknown() protected method

Handler of non-known signals.
protected sigunknown ( $signo ) : void
return void

sigusr1() protected method

Handler of the SIGUSR1 (re-open log-file) signal in worker process.
protected sigusr1 ( ) : void
return void

sigusr2() protected method

Handler of the SIGUSR2 (graceful shutdown for update) signal in worker process.
protected sigusr2 ( ) : void
return void

update() protected method

Reloads additional config-files on-the-fly.
protected update ( ) : void
return void

Property Details

$IPCManager public_oe property

public IPCManager,PHPDaemon\IPCManager $IPCManager
return PHPDaemon\IPCManager\IPCManager

$autoReloadLast protected_oe property

Last time of auto reload
protected int $autoReloadLast
return integer

$breakMainLoop public_oe property

Break main loop?
public bool $breakMainLoop
return boolean

$connection public_oe property

Connection
public Connection $connection
return Connection

$counterGC public_oe property

Counter GC
public int $counterGC
return integer

$delayedSigReg protected_oe property

If true, we do not register signals automatically at start
protected bool $delayedSigReg
return boolean

$graceful protected_oe property

protected $graceful

$instancesCount public_oe property

Instances count
public array $instancesCount
return array

$lambdaCache public_oe property

public $lambdaCache

$reload public_oe property

Reload?
public bool $reload
return boolean

$reloadDelay protected_oe property

Reload delay
protected int $reloadDelay
return integer

$reloadReady public_oe property

Reload ready?
public bool $reloadReady
return boolean

$reloaded public_oe property

Reloaded?
public bool $reloaded
return boolean

$reqCounter public_oe property

Request counter
public int $reqCounter
return integer

$state public_oe property

State
public int $state
return integer

$timeLastActivity public_oe property

Time of last activity
public int $timeLastActivity
return integer

$update public_oe property

Update?
public bool $update
return boolean