Back to Joomla project (class list)

Class DaemonApplication - list of methods

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

Extends

Package: Joomla\CMS\Application
Copyright: (C) 2012 Open Source Matters, Inc.
License: GNU General Public License version 2 or later; see LICENSE.txt
Located at: Joomla/Application/DaemonApplication.php
Project: Joomla

Method Summary

public
(\Joomla\CMS\Input\Cli $input = null, \Joomla\Registry\Registry $config = null, \Joomla\Event\DispatcherInterface $dispatcher = null)

Class constructor.
Parameters
  • \Joomla\CMS\Input\Cli $input An optional argument to provide dependency injection for the application's input object. If the argument is a JInputCli object that object will become the application's input object, otherwise a default input object is created.
  • \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.
  • \Joomla\Event\DispatcherInterface $dispatcher An optional argument to provide dependency injection for the application's event dispatcher. If the argument is a DispatcherInterface object that object will become the application's event dispatcher, if it is null then the default event dispatcher will be created based on the application's loadDispatcher() method.
Since
  • 1.7.0
Show source code of this method: __construct Source Code

public static void
(mixed $signal)

Method to handle POSIX signals.
Parameters
  • int $signal The received POSIX signal.
Returns
  • void
Since
  • 1.7.0
-
  • \Joomla\CMS\Application\pcntl_signal()
  • \RuntimeException
Show source code of this method: signal Source Code

public bool
()

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
  • bool True if daemon is active.
Since
  • 1.7.0
Show source code of this method: isActive Source Code

public \Joomla\CMS\Application\DaemonApplication
(mixed $data)

Load an object or array into the application configuration object.
Parameters
  • mixed $data Either an array or object to be loaded into the configuration object.
Returns
  • \Joomla\CMS\Application\DaemonApplication Instance of $this to allow chaining.
Since
  • 1.7.0
Show source code of this method: loadConfiguration Source Code

public void
()

Execute the daemon.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: execute Source Code

public void
()

Restart daemon process.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: restart Source Code

public void
()

Stop daemon process.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: stop Source Code

protected bool
()

Method to change the identity of the daemon process and resources.
Returns
  • bool True if identity successfully changed
Since
  • 1.7.0
-
  • \Joomla\CMS\Application\posix_setuid()
Show source code of this method: changeIdentity Source Code

protected bool
()

Method to put the application into the background.
Returns
  • bool
Since
  • 1.7.0
-
  • \RuntimeException
Show source code of this method: daemonize Source Code

protected void
()

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.
Returns
  • void
Since
  • 3.0.0
-
  • \RuntimeException
Show source code of this method: detach Source Code

protected int
()

Method to fork the process.
Returns
  • int The child process id to the parent process, zero to the child process.
Since
  • 1.7.0
-
  • \RuntimeException
Show source code of this method: fork Source Code

protected void
()

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.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: gc Source Code

protected bool
()

Method to attach the DaemonApplication signal handler to the known signals. Applications can override these handlers by using the pcntl_signal() function and attaching a different callback method.
Returns
  • bool
Since
  • 1.7.0
-
  • \Joomla\CMS\Application\pcntl_signal()
Show source code of this method: setupSignalHandlers Source Code

protected void
(mixed $restart = false)

Method to shut down the daemon and optionally restart it.
Parameters
  • bool $restart True to restart the daemon on exit.
Returns
  • void
Since
  • 1.7.0
Show source code of this method: shutdown Source Code

protected bool
()

Method to write the process id file out to disk.
Returns
  • bool
Since
  • 1.7.0
Show source code of this method: writeProcessIdFile Source Code

protected void
()

Method to handle post-fork triggering of the onFork event.
Returns
  • void
Since
  • 3.0.0
Show source code of this method: postFork Source Code

protected int
(mixed $status)

Method to return the exit code of a terminated child process.
Parameters
  • int $status The status parameter is the status parameter supplied to a successful call to pcntl_waitpid().
Returns
  • int The child process exit code.
Since
  • 1.7.3
-
  • \Joomla\CMS\Application\pcntl_wexitstatus()
Show source code of this method: pcntlChildExitStatus Source Code

protected int
()

Method to return the exit code of a terminated child process.
Returns
  • int 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.7.3
-
  • \Joomla\CMS\Application\pcntl_fork()
Show source code of this method: pcntlFork Source Code

protected bool
(mixed $signal, mixed $handler, mixed $restart = true)

Method to install a signal handler.
Parameters
  • int $signal The signal number.
  • 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.
  • bool $restart Specifies whether system call restarting should be used when this signal arrives.
Returns
  • bool True on success.
Since
  • 1.7.3
-
  • \Joomla\CMS\Application\pcntl_signal()
Show source code of this method: pcntlSignal Source Code

protected int
(mixed &$status, mixed $options = 0)

Method to wait on or return the status of a forked child.
Parameters
  • int & $status Status information.
  • int $options If wait3 is available on your system (mostly BSD-style systems), you can provide the optional options parameter.
Returns
  • int 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.7.3
-
  • \Joomla\CMS\Application\pcntl_wait()
Show source code of this method: pcntlWait Source Code

Properties Summary

protected static array
$signals
Since
  • 1.7.0
-
  • array
protected bool
$exiting
Since
  • 1.7.0
protected int
$parentId
Since
  • 3.0.0
protected int
$processId
Since
  • 1.7.0
protected bool
$running
Since
  • 1.7.0

Tags Summary

Since
1.7.0