$name
$name : string
Name prefix to be used on files associated with this daemon (such as lock like and messages)
Used to run scripts as a daemon on *nix systems
processHandler(boolean $continue = false)
Tick callback function used to update the timestamp in this processes lock. If lock_file does not exist or more than PROCESS_TIMEOUT time has elapsed since the last processHandler call it stops the process
boolean | $continue | if true only stop if lock file not present, ignore PROCESS_TIMEOUT time being exceeded. |
init(array $init_argv, string $name, integer $exit_type = 1, string $use_message = "")
Used to send a message the given daemon or run the program in the foreground.
array | $init_argv | an array of command line arguments. The argument start will check if the process control functions exists if these do they will fork and detach a child process to act as a daemon. a lock file will be created to prevent additional daemons from running. If the message is stop then a message file is written to tell the daemon to stop. If the argument is terminal then the program won't be run as a daemon. |
string | $name | the prefix to use for lock and message files |
integer | $exit_type | whether this function should exit > 0 or return (1) by default a lock file is only written if exit (this allows both queue server processes (Indexer and Scheduler) to use the same lock file. If exit is >=3 or <= -3 then doesn't check lock to see if already running before starting |
string | $use_message | echo'd if incorrect parameters sent |
daemonLog(string $msg, integer $exit_type)
Used to print a log message in a way helpful to aid debugging CrawlDaemon tasks where crawlLog() might not yet be set up Sends the message to stardard out if crawlLog not set up; otherwise, sends to crawlLog()
string | $msg | string to log to either standard out or to Yioop's crawlLog |
integer | $exit_type | the exit_type used by init() and start() values of absolute value >2 are only used if crawlLog has already been set up |
start(string $name, string $subname = "", string $options = "", integer $exit = 1)
Used to start a daemon running in the background
string | $name | the main name of this daemon such as queue_server or fetcher. |
string | $subname | the instance name if it is possible for more than one copy of the daemon to be running at the same time |
string | $options | a string of additional command line options |
integer | $exit | whether this function should exit > 0 or return (1) by default a lock file is only written if exit (this allows both queue server processes (Indexer and Scheduler) to use the same lock file. If exit is >=3 or <= -3 then doesn't check lock to see if already running before starting |
stop(string $name, string $subname = "", boolean $exit = true)
Used to stop a daemon that is running in the background
string | $name | the main name of this daemon such as QueueServer or Fetcher. |
string | $subname | the instance name if it is possible for more than one copy of the daemon to be running at the same time |
boolean | $exit | whether this method should just return (false) or call exit() (true) |
getMesssageFileName(string $name, string $subname = "") : string
Used to return the string name of the messages file used to pass messages to a daemon running in the background
string | $name | the main name of this daemon such as queue_server or fetcher. |
string | $subname | the instance name if it is possible for more than one copy of the daemon to be running at the same time |
the name of the message file for the daemon with the given name and subname
getLockFileName(string $name, string $subname = "") : string
Used to return the string name of the lock file used to pass by a daemon
string | $name | the main name of this daemon such as queue_server or fetcher. |
string | $subname | the instance name if it is possible for more than one copy of the daemon to be running at the same time |
the name of the lock file for the daemon with the given name and subname
getNameString(string $name, string $subname) : string
Used to return a string name for a given daemon instance
string | $name | the main name of this daemon such as queue_server or fetcher. |
string | $subname | the instance name if it is possible for more than one copy of the daemon to be running at the same time |
a single name that combines the name and subname