Class: System_Daemon
Source Location: /System_Daemon-1.0.0/System/Daemon.php
System_Daemon. Create daemons with practicle functions like System_Daemon::start()
Author(s):
Version:
Copyright:
- 2008 Kevin van Zonneveld (http://kevin.vanzonneveld.net)
|
|
|
Inherited Variables
|
Inherited Methods
|
Class Details
Class Variables
Method Detail
abbr [line 820]
string abbr(
string
$str, [integer
$cutAt = 30], [string
$suffix = '...'])
|
|
Abbreviate a string. e.g: Kevin van zonneveld -> Kevin van Z...
Parameters:
alert [line 882]
autoload [line 450]
void autoload(
string
$className)
|
|
Autoload static method for loading classes and interfaces. Code from the PHP_CodeSniffer package by Greg Sherwood and Marc McIntyre
Parameters:
crit [line 894]
debug [line 954]
defaultSigHandler [line 1209]
void defaultSigHandler(
integer
$signo)
|
|
Default signal handler. You can overrule various signals with the setSigHandler() method
Parameters:
emerg [line 870]
err [line 906]
fileread [line 1454]
string fileread(
string
$filepath)
|
|
Read a file. file_get_contents() leaks memory! (#18031 for more info)
Parameters:
getOption [line 753]
mixed getOption(
string
$name)
|
|
Gets any option found in $_optionDefinitions Public interface to talk with with protected option methods
Parameters:
getOptions [line 767]
Gets an array of options found
info [line 942]
isDying [line 1257]
Whether the our daemon is being killed, you might want to include this in your loop
isInBackground [line 1246]
boolean isInBackground(
)
|
|
Whether the class is already running in the background
isRunning [line 1267]
Check if a previous process with same pidfile was already running
iterate [line 624]
void iterate(
[integer
$sleepSeconds = 0])
|
|
Protects your daemon by e.g. clearing statcache. Can optionally be used as a replacement for sleep as well.
Parameters:
log [line 1035]
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::opt('usePEAR'). Also supports PEAR_Log if you referenc to a valid instance of it in self::opt('usePEARLogInstance'). It logs a string according to error levels specified in array: self::$_logLevels (0 is fatal and handles daemon's death)
Parameters:
__construct (Constructor) [line 434]
System_Daemon __construct(
)
|
|
Making the class non-abstract with a protected constructor does a better job of preventing instantiation than just marking the class as abstract.
notice [line 930]
opt [line 734]
Shortcut for getOption & setOption
Parameters:
phpErrors [line 786]
boolean phpErrors(
integer
$errno, string
$errstr, string
$errfile, integer
$errline)
|
|
Catches PHP Errors and forwards them to log function
Parameters:
restart [line 661]
semantify [line 839]
string semantify(
mixed
$arguments)
|
|
Tries to return the most significant information as a string based on any given argument.
Parameters:
setOption [line 701]
boolean setOption(
string
$name, mixed
$value)
|
|
Sets any option found in $_optionDefinitions Public interface to talk with with protected option methods
Parameters:
setOptions [line 718]
boolean setOptions(
array
$use_options)
|
|
Sets an array of options found in $_optionDefinitions Public interface to talk with with protected option methods
Parameters:
setSigHandler [line 676]
boolean setSigHandler(
string
$signal, mixed
$handler)
|
|
Overrule or add signal handlers.
Parameters:
start [line 494]
stop [line 649]
warning [line 918]
writeAutoRun [line 1162]
boolean writeAutoRun(
[boolean
$overwrite = false])
|
|
Uses OS class to write an: 'init.d' script on the filesystem
Parameters:
_changeIdentity [line 1486]
boolean _changeIdentity(
[integer
$gid = 0], [integer
$uid = 0])
|
|
Change identity of process & resources if needed.
Parameters:
_die [line 1599]
void _die(
[boolean
$restart = false])
|
|
Sytem_Daemon::_die() Kill the daemon Keep this function as independent from complex logic as possible
Parameters:
_fork [line 1559]
Fork process and kill parent process, the heart of the 'daemonization'
_ilog [line 970]
boolean _ilog(
mixed
$level, mixed
$str)
|
|
Internal logging function. Bridge between shortcuts like: err(), warning(), info() and the actual log() function
Parameters:
_isValidPidLocation [line 1391]
boolean _isValidPidLocation(
string
$pidFilePath, [boolean
$log = true])
|
|
Determine whether pidfilelocation is valid
Parameters:
_mkdirr [line 1472]
boolean _mkdirr(
string
$dirPath, integer
$mode)
|
|
Recursive alternative to mkdir
Parameters:
_optionObjSetup [line 1657]
boolean _optionObjSetup(
)
|
|
Sets up Option Object instance
_optionsInit [line 1680]
mixed _optionsInit(
[boolean
$premature = false])
|
|
Checks if all the required options are set. Initializes, sanitizes & defaults unset variables
Parameters:
_osObjSetup [line 1637]
_summon [line 1301]
Put the running script in background
_whatIAm [line 1585]
Return what the current process is: child or parent
_writePid [line 1420]
boolean _writePid(
[string
$pidFilePath = null], [integer
$pid = null])
|
|
Creates pid dir and writes process id to pid file
Parameters:
Documentation generated on Mon, 11 Mar 2019 15:47:42 -0400 by phpDocumentor 1.4.4. PEAR Logo Copyright © PHP Group 2004.
|
|