System_Daemon
[ class tree: System_Daemon ] [ index: System_Daemon ] [ all elements ]

Class: System_Daemon

Source Location: /System_Daemon-0.5.0/System/Daemon.php

Class Overview


System_Daemon. Create daemons with practicle functions like $daemon->start()


Author(s):

Version:

  • SVN: Release: $Id: Daemon.php 149 2008-07-21 12:26:28Z kevin $

Copyright:

  • 2008 Kevin van Zonneveld (http://kevin.vanzonneveld.net)

Methods


Inherited Variables

Inherited Methods


Class Details

[line 39]
System_Daemon. Create daemons with practicle functions like $daemon->start()

Requires PHP build with --enable-cli --with-pcntl. Only runs on *NIX systems, because Windows lacks of the pcntl ext.

PHP version 5



[ Top ]


Method Detail

autoload   [line 321]

void autoload( string $className)

Autoload static method for loading classes and interfaces.

Code from the PHP_CodeSniffer package by Greg Sherwood and Marc McIntyre

  • Access: public

Parameters:

string   $className   —  The name of the class or interface.

[ Top ]

defaultSigHandler   [line 712]

void defaultSigHandler( integer $signo)

Default signal handler.

You can overrule various signals with the setSigHandler() method


Parameters:

integer   $signo   —  The posix signal received.

[ Top ]

getOption   [line 515]

mixed getOption( string $name)

Gets any option found in $_optionDefinitions Public interface to talk with with private option methods
  • Access: public

Parameters:

string   $name   —  Name of the Option

[ Top ]

getOptions   [line 529]

array getOptions( )

Gets an array of options found
  • Access: public

[ Top ]

isDying   [line 766]

boolean isDying( )

Wether the our daemon is being killed, you might want to include this in your loop
  • Access: public

[ Top ]

isInBackground   [line 755]

boolean isInBackground( )

Wether the class is already running in the background
  • Access: public

[ Top ]

isRunning   [line 776]

boolean isRunning( )

Check if a previous process with same pidfile was already running
  • Access: public

[ Top ]

log   [line 562]

boolean log( integer $level, string $str, [string $file = false], [string $class = false], [string $function = false], [integer $line = false])

Almost every deamon requires a log file, this function can facilitate that. Also handles class-generated errors, chooses either PEAR handling or PEAR-independant handling, depending on: self::getOption("usePEAR").

Also supports PEAR_Log if you referenc to a valid instance of it in self::getOption("usePEARLogInstance").

It logs a string according to error levels specified in array: self::$_logLevels (0 is fatal and handles daemon's death)

  • See: _logLevels
  • See: logLocation
  • Throws: System_Daemon_Exception
  • Access: public

Parameters:

integer   $level   —  What function the log record is from
string   $str   —  The log record
string   $file   —  What code file the log record is from
string   $class   —  What class the log record is from
string   $function   —  What function the log record is from
integer   $line   —  What code line the log record is from

[ Top ]

setOption   [line 481]

boolean setOption( string $name, mixed $value)

Sets any option found in $_optionDefinitions Public interface to talk with with private option methods
  • Access: public

Parameters:

string   $name   —  Name of the Option
mixed   $value   —  Value of the Option

[ Top ]

setOptions   [line 498]

boolean setOptions( array $use_options)

Sets an array of options found in $_optionDefinitions Public interface to talk with with private option methods
  • Access: public

Parameters:

array   $use_options   —  Array with Options

[ Top ]

setSigHandler   [line 457]

boolean setSigHandler( string $signal, mixed $handler)

Overrule or add signal handlers.
  • See: $_sigHandlers
  • Access: public

Parameters:

string   $signal   —  Signal constant (e.g. SIGHUP)
mixed   $handler   —  Which handler to call on signal

[ Top ]

start   [line 353]

boolean start( )

Spawn daemon process.

[ Top ]

stop   [line 439]

void stop( )

Stop daemon process.

[ Top ]

writeAutoRun   [line 666]

boolean writeAutoRun( [boolean $overwrite = false])

Uses OS class to write an: 'init.d' script on the filesystem
  • Access: public

Parameters:

boolean   $overwrite   —  May the existing init.d file be overwritten?

[ Top ]


Documentation generated on Thu, 10 Dec 2015 05:50:59 +0000 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.