JOOMLA中国
  • Joomla中国首页
  • 社区
  • 教程
  • 应用市场
  • B计划
Joomla! Framework TM
  • Namespace
  • Class
  • Tree
  • Deprecated

Namespaces

  • Composer
    • Autoload
  • Joomla
    • Application
      • Cli
        • Output
          • Processor
      • Web
    • Data
    • DI
      • Exception
    • Event
    • Filter
    • Input
    • Ldap
    • Registry
      • Format
    • Session
      • Storage
    • String
    • Uri
    • Utilities
  • None
  • PasswordCompat
    • binary
  • PHP
  • Psr
    • Log
  • Symfony
    • Component
      • Yaml
        • Exception
    • Polyfill
      • Util

Classes

  • AbstractApplication
  • AbstractCliApplication
  • AbstractDaemonApplication
  • AbstractWebApplication

Class AbstractDaemonApplication

Class to turn Cli applications into daemons. It requires CLI and PCNTL support built into PHP.

Joomla\Application\AbstractApplication implements Psr\Log\LoggerAwareInterface
Extended by Joomla\Application\AbstractCliApplication
Extended by Joomla\Application\AbstractDaemonApplication implements Psr\Log\LoggerAwareInterface
Abstract
Namespace: Joomla\Application
Since: 1.0
See: http://www.php.net/manual/en/book.pcntl.php
See: http://php.net/manual/en/features.commandline.php
Located at vendor/joomla/application/src/AbstractDaemonApplication.php

Methods summary

public
# __construct( Joomla\Application\Cli $input = null, Joomla\Registry\Registry $config = null, Joomla\Application\Cli\CliOutput $output = null, Joomla\Application\Cli\CliInput $cliInput = null )

Class constructor.

Class constructor.

Parameters

$input
Joomla\Input\Cli - $input An optional argument to provide dependency injection for the application's input object. If the argument is an Input\Cli object that object will become the application's input object, otherwise a default input object is created.
$config
Joomla\Registry\Registry - $config An optional argument to provide dependency injection for the application's config object. If the argument is a Registry object that object will become the application's config object, otherwise a default config object is created.
$output
Joomla\Application\Cli\CliOutput - $output An optional argument to provide dependency injection for the application's output object. If the argument is a Cli\CliOutput object that object will become the application's input object, otherwise a default output object is created.
$cliInput
Joomla\Application\Cli\CliInput - $cliInput An optional argument to provide dependency injection for the application's CLI input object. If the argument is a Cli\CliInput object that object will become the application's input object, otherwise a default input object is created.

Since

1.0

Overrides

Joomla\Application\AbstractCliApplication::__construct
public
# signal( integer $signal )

Method to handle POSIX signals.

Method to handle POSIX signals.

Parameters

$signal
integer - $signal The received POSIX signal.

Throws

RuntimeException

Since

1.0

See

pcntl_signal()
public boolean
# isActive( )

Check to see if the daemon is active. This does not assume that $this daemon is active, but only if an instance of the application is active as a daemon.

Check to see if the daemon is active. This does not assume that $this daemon is active, but only if an instance of the application is active as a daemon.

Returns

boolean - True if daemon is active.

Since

1.0
public Joomla\Application\AbstractDaemonApplication
# loadConfiguration( mixed $data )

Load an object or array into the application configuration object.

Load an object or array into the application configuration object.

Parameters

$data
mixed - $data Either an array or object to be loaded into the configuration object.

Returns

Joomla\Application\AbstractDaemonApplication - Instance of $this to allow chaining.

Since

1.0
public
# execute( )

Execute the daemon.

Execute the daemon.

Since

1.0

Overrides

Joomla\Application\AbstractApplication::execute
public
# restart( )

Restart daemon process.

Restart daemon process.

Since

1.0

CodeCoverageIgnore

public
# stop( )

Stop daemon process.

Stop daemon process.

Since

1.0

CodeCoverageIgnore

protected boolean
# changeIdentity( )

Method to change the identity of the daemon process and resources.

Method to change the identity of the daemon process and resources.

Returns

boolean - True if identity successfully changed

Since

1.0

See

posix_setuid()
protected boolean
# daemonize( )

Method to put the application into the background.

Method to put the application into the background.

Returns

boolean

Throws

RuntimeException

Since

1.0
protected
# detach( )

This is truly where the magic happens. This is where we fork the process and kill the parent process, which is essentially what turns the application into a daemon.

This is truly where the magic happens. This is where we fork the process and kill the parent process, which is essentially what turns the application into a daemon.

Throws

RuntimeException

Since

1.0
protected integer
# fork( )

Method to fork the process.

Method to fork the process.

Returns

integer - The child process id to the parent process, zero to the child process.

Throws

RuntimeException

Since

1.0
protected
# gc( )

Method to perform basic garbage collection and memory management in the sense of clearing the stat cache. We will probably call this method pretty regularly in our main loop.

Method to perform basic garbage collection and memory management in the sense of clearing the stat cache. We will probably call this method pretty regularly in our main loop.

Since

1.0

CodeCoverageIgnore

protected boolean
# setupSignalHandlers( )

Method to attach the AbstractDaemonApplication signal handler to the known signals. Applications can override these handlers by using the pcntl_signal() function and attaching a different callback method.

Method to attach the AbstractDaemonApplication signal handler to the known signals. Applications can override these handlers by using the pcntl_signal() function and attaching a different callback method.

Returns

boolean

Since

1.0

See

pcntl_signal()
protected
# shutdown( boolean $restart = false )

Method to shut down the daemon and optionally restart it.

Method to shut down the daemon and optionally restart it.

Parameters

$restart
boolean - $restart True to restart the daemon on exit.

Since

1.0
protected boolean
# writeProcessIdFile( )

Method to write the process id file out to disk.

Method to write the process id file out to disk.

Returns

boolean

Since

1.0
protected
# postFork( )

Method to handle post-fork triggering of the onFork event.

Method to handle post-fork triggering of the onFork event.

Since

1.0
protected integer
# pcntlChildExitStatus( integer $status )

Method to return the exit code of a terminated child process.

Method to return the exit code of a terminated child process.

Parameters

$status
integer - $status The status parameter is the status parameter supplied to a successful call to pcntl_waitpid().

Returns

integer - The child process exit code.

Since

1.0

See

pcntl_wexitstatus()

CodeCoverageIgnore

protected integer
# pcntlFork( )

Method to return the exit code of a terminated child process.

Method to return the exit code of a terminated child process.

Returns

integer - On success, the PID of the child process is returned in the parent's thread of execution, and a 0 is returned in the child's thread of execution. On failure, a -1 will be returned in the parent's context, no child process will be created, and a PHP error is raised.

Since

1.0

See

pcntl_fork()

CodeCoverageIgnore

protected boolean
# pcntlSignal( integer $signal, callable $handler, boolean $restart = true )

Method to install a signal handler.

Method to install a signal handler.

Parameters

$signal
integer - $signal The signal number.
$handler
callable - $handler The signal handler which may be the name of a user created function, or method, or either of the two global constants SIG_IGN or SIG_DFL.
$restart
boolean - $restart Specifies whether system call restarting should be used when this signal arrives.

Returns

boolean - True on success.

Since

1.0

See

pcntl_signal()

CodeCoverageIgnore

protected integer
# pcntlWait( integer & $status, integer $options = 0 )

Method to wait on or return the status of a forked child.

Method to wait on or return the status of a forked child.

Parameters

$status
integer - &$status Status information.
$options
integer - $options If wait3 is available on your system (mostly BSD-style systems), you can provide the optional options parameter.

Returns

integer - The process ID of the child which exited, -1 on error or zero if WNOHANG was provided as an option (on wait3-available systems) and no child was available.

Since

1.0

See

pcntl_wait()

CodeCoverageIgnore

Methods inherited from Joomla\Application\AbstractCliApplication

getCliInput(), getOutput(), in(), out()

Methods inherited from Joomla\Application\AbstractApplication

close(), doExecute(), get(), getLogger(), initialise(), set(), setConfiguration(), setLogger()

Magic methods summary

Properties summary

protected static array $signals
#

The available POSIX signals to be caught by default.

The available POSIX signals to be caught by default.

Since

1.0

See

http://php.net/manual/pcntl.constants.php
protected boolean $exiting
#

True if the daemon is in the process of exiting.

True if the daemon is in the process of exiting.

Since

1.0
protected integer $parentId
#

The parent process id.

The parent process id.

Since

1.0
protected integer $processId
#

The process id of the daemon.

The process id of the daemon.

Since

1.0
protected boolean $running
#

True if the daemon is currently running.

True if the daemon is currently running.

Since

1.0

Properties inherited from Joomla\Application\AbstractCliApplication

$cliInput, $output

Properties inherited from Joomla\Application\AbstractApplication

$config, $input

Joomla! Framework TM API documentation generated by ApiGen 2.8.0
Joomla!® and Joomla! Framework™ are trademarks of Open Source Matters, Inc. in the United States and other countries.