Proposal for "Daemon"

» Metadata » Status
» Description
System_Daemon turns PHP-CLI scripts into daemons (background processes on Linux).

Some features:
  1. Support for PEAR's Log package
  2. Simple syntax
  3. Methods to determine OS and write startup files (init.d)
  4. Can run with or without PEAR (PEAR adds more elegance & functionality)
  5. Default signal handlers, but optionally reroute signals to your own handlers.
  6. Log levels comply with PEAR_LOG_ levels but are called SYSTEM_DAEMON_LOG_ for (in)dependency reasons
  7. Set options like max RAM usage

Minimalistic Usage Example:

<?php
require_once "System/Deamon.php";

// Set at least these properties
System_Daemon::$appName = "simple";
System_Daemon::$appDir = dirname(__FILE__);

System_Daemon::log(1, "Daemon not yet summoned. Writing this to STDOUT");

// Spawn Deamon!
System_Daemon::start();
System_Daemon::log(1, "Daemon: 'simple' summoned! Writing this to /var/log/simple.log");

// Your normal PHP code goes here. Only now the code will run in the
// background so you can close your terminal session, and the application
// will still run.

System_Daemon::stop();
?>
» Dependencies » Links
  • Linux
  • --enable-cli
  • --with-pcntl
» Timeline » Changelog
  • First Draft: 2008-04-19
  • Proposal: 2008-04-28
  • Call for Votes: 2008-05-10
  • Voting Extended: 2008-05-18
  • Kevin van Zonneveld
    [2008-05-07 16:18 UTC]

    2008-04-29 Kevin van Zonneveld

    [r86] Added optional support for acceptance of an instance of PEAR's Log package
    [r84] Improved code layout
    [r81] Improved SAFE_MODE check
    [r80] Added a 'nopear' example
    [r78] Allowed for ini_sets to be defined outside of the class
    [r78] Enabled a SAFE_MODE check for the ini_sets
    [r77] Made log levels comply with PEAR_LOG_ levels.
    [r76] You can now pass your own custom handlers to the various sig states.
    [r75] Improved the packaging tools

    2008-04-28 Kevin van Zonneveld

    [r74] Remove error_reporting all (debug purposes)
    [r73] Fixed abstraction related pcntl_signal bug
    [r72] Protected members must not be prefixed with an underscore
    [r70] Improved function hierarchy (static, protected, etc)
    [r69] Improved independency of OS class by pushing properties from parent object
    [r68] Ignore project file

    2008-04-27 Kevin van Zonneveld

    [r67] Instantiating the Daemon is foolish. Therefore change the entire package to abstract.
    [r63] Stripped some default unit tests that are not going to be compatible with the actuall daemon mechanism
    [r62] Include tgz package in SVN
    [r61] Improved the packaging tools
    [r60] Improved the unit tests
    [r59] Becoming a daemon breaks the PHPUnit test mechanism.
    [r57] Added basic Unit Test
    [r57] Moved OS functions to own class

    2008-04-24 Kevin van Zonneveld

    [r56] Improved the packaging tools
    [r55] Improved the tools

    2008-04-23 Kevin van Zonneveld

    [r54] Improved the examples
    [r53] Created tools for package & changelog generation
    [r52] Delete tools. svn2cl is in subversion-tools package.
    [r51] Reorganize directory structure
    [r50] Package.xml