PHP 클래스 vyants\daemon\DaemonController

저자: Vladimir Yants ([email protected])
상속: extends yii\console\Controller
파일 보기 프로젝트 열기: vyants/yii2-daemon 1 사용 예제들

공개 프로퍼티들

프로퍼티 타입 설명
$demonize boolean Run controller as Daemon
$isMultiInstance boolean allow daemon create a few instances
$maxChildProcesses int max daemon instances

보호된 프로퍼티들

프로퍼티 타입 설명
$currentJobs [] array of running instances
$logDir
$memoryLimit Memory limit for daemon, must bee less than php memory_limit
$parentPID int main procces pid
$pidDir
$sleep Delay between task list checking

공개 메소드들

메소드 설명
__destruct ( )
actionIndex ( ) : boolean Base action, you can\t override or create another actions
beforeAction ( Action $action ) : boolean Prevent non index action running
getPidPath ( string $daemon = null ) : string
getProcessName ( $route = null ) : string
init ( ) Init function
options ( string $actionID ) : array Возвращает доступные опции
runDaemon ( string $job ) : boolean Tasks runner
signalHandler ( $signo, null $pid = null, null $status = null ) PCNTL signals handler
stderr ( string $string ) : integer If in daemon mode - no write to console
stdout ( string $string ) : boolean | integer If in daemon mode - no write to console

보호된 메소드들

메소드 설명
changeProcessName ( ) Set new process name
cleanLog ( ) Empty log queue
closeStdStreams ( ) Close std streams and open to /dev/null need some class properties
defineJobExtractor ( &$jobs ) : mixed Fetch one task from array of tasks
defineJobs ( ) : array Extract current unprocessed jobs You can extract jobs from DB (DataProvider will be great), queue managers (ZMQ, RabbiMQ etc), redis and so on
deletePid ( ) Delete pid file
doJob ( $job ) : boolean Daemon worker body
flushLog ( $final = false ) Empty log queue
halt ( $code, $message = null ) Stop process and show or write message
initLogger ( ) Adjusting logger. You can override it.
renewConnections ( ) Renew connections

비공개 메소드들

메소드 설명
loop ( ) : boolean Main Loop
writeConsole ( $message ) Show message in console

메소드 상세

__destruct() 공개 메소드

public __destruct ( )

actionIndex() 최종 공개 메소드

Base action, you can\t override or create another actions
final public actionIndex ( ) : boolean
리턴 boolean

beforeAction() 공개 메소드

Prevent non index action running
public beforeAction ( Action $action ) : boolean
$action yii\base\Action
리턴 boolean

changeProcessName() 보호된 메소드

Set new process name
protected changeProcessName ( )

cleanLog() 보호된 메소드

Empty log queue
protected cleanLog ( )

closeStdStreams() 보호된 메소드

Close std streams and open to /dev/null need some class properties
protected closeStdStreams ( )

defineJobExtractor() 보호된 메소드

Fetch one task from array of tasks
protected defineJobExtractor ( &$jobs ) : mixed
리턴 mixed one task

defineJobs() 추상적인 보호된 메소드

Extract current unprocessed jobs You can extract jobs from DB (DataProvider will be great), queue managers (ZMQ, RabbiMQ etc), redis and so on
abstract protected defineJobs ( ) : array
리턴 array with jobs

deletePid() 보호된 메소드

Delete pid file
protected deletePid ( )

doJob() 추상적인 보호된 메소드

Daemon worker body
abstract protected doJob ( $job ) : boolean
$job
리턴 boolean

flushLog() 보호된 메소드

Empty log queue
protected flushLog ( $final = false )

getPidPath() 공개 메소드

public getPidPath ( string $daemon = null ) : string
$daemon string
리턴 string

getProcessName() 공개 메소드

public getProcessName ( $route = null ) : string
리턴 string

halt() 보호된 메소드

Stop process and show or write message
protected halt ( $code, $message = null )
$code int -1|0|1
$message string

init() 공개 메소드

Init function
public init ( )

initLogger() 보호된 메소드

Adjusting logger. You can override it.
protected initLogger ( )

options() 공개 메소드

Возвращает доступные опции
public options ( string $actionID ) : array
$actionID string
리턴 array

renewConnections() 보호된 메소드

Renew connections
protected renewConnections ( )

runDaemon() 최종 공개 메소드

Tasks runner
final public runDaemon ( string $job ) : boolean
$job string
리턴 boolean

signalHandler() 최종 정적인 공개 메소드

PCNTL signals handler
final static public signalHandler ( $signo, null $pid = null, null $status = null )
$signo
$pid null
$status null

stderr() 공개 메소드

If in daemon mode - no write to console
public stderr ( string $string ) : integer
$string string
리턴 integer

stdout() 공개 메소드

If in daemon mode - no write to console
public stdout ( string $string ) : boolean | integer
$string string
리턴 boolean | integer

프로퍼티 상세

$currentJobs 보호되어 있는 정적으로 프로퍼티

[] array of running instances
protected static $currentJobs

$demonize 공개적으로 프로퍼티

boolean Run controller as Daemon
public $demonize

$isMultiInstance 공개적으로 프로퍼티

boolean allow daemon create a few instances
public $isMultiInstance

$logDir 보호되어 있는 프로퍼티

protected $logDir

$maxChildProcesses 공개적으로 프로퍼티

int max daemon instances
public $maxChildProcesses

$memoryLimit 보호되어 있는 프로퍼티

Memory limit for daemon, must bee less than php memory_limit
protected $memoryLimit

$parentPID 보호되어 있는 프로퍼티

int main procces pid
protected $parentPID

$pidDir 보호되어 있는 프로퍼티

protected $pidDir

$sleep 보호되어 있는 프로퍼티

Delay between task list checking
protected $sleep