Comments for "Daemon"

» Submit Your Comment
Comments are only accepted during the "Proposal" phase. This proposal is currently in the "Finished" phase.
» Comments
  • Joe Stump  [2008-04-28 17:38 UTC]

    1.) I'd like to see the daemon's logging functionality accept an instance of PEAR's Log package optionally.

    2.) Why not just require System_Daemon_Exception rather than check for it's existence and then throw a regular exception?

    3.) If you don't use PEAR's Log (which would be a bummer) then I'd add class constants for the log levels.

    4.) I'm unsure what PEAR's stance on autoload() functions is at this point. Also, if you use that you'll need to add spl to your list of dependencies.

    5.) I don't think trigger_error() is acceptable error handling for PEAR packages at this point. I'd change all of those to throw System_Daemon_Exception.

    6.) I'd change a lot of those ini_set() to be options that can be defined somehow. Also, I'd check to make sure we aren't in safe mode before doing such things.

    7.) I'd like to see a way where I could pass my own custom handlers to the various sig states.

    I was thinking of writing something similar to this for Digg recently so this is a package I'd like to see in PEAR. That being said, I'd like to see a package where I can extend the core daemon script to make my class into a daemon, overload signal functions, etc.
  • Kevin van Zonneveld  [2008-04-29 18:10 UTC]

    Thanks for your input Joe, I've made a first attempt to implement your suggestions. I'll walk through them:

    1.) Agreed. I've implemented it with/in: $usePEARLogInstance, log(), and the pearlog.php example

    2.) Cause in it's current form, System_Daemon also works if you don't have PEAR on a server. Projects that only run linux & php-cli can still run the System_Daemon class. Personally I would like to maintain this duality but if this is a deal breaker I can always remove all the conditional PEAR-independent-code & make it PEAR-only. But I believe it all works like it should now.

    More on this case specifically: System_Daemon_Exception obviously extends PEAR_Exception, so that's the reason why I've made it conditional. And checking for it's existence seemed elegant because Autoload should make sure the System_Daemon_Exception is included automatically and is always thrown if the class was running in PEAR-mode.

    3.) Agreed. I've changed the log constants to match PEAR_Log's values. I do still use a duplicate set though, for reasons described in (2), but the constants' values are interchangeable now so I think that should offer adequate compliance.

    4.) I had hoped requiring PHP 5 >= 5.1.2 would solve this issue. I don't know PEAR's official stance in the autoload matter, I could not find it in the documentation. But I've seen the PHP_CodeSniffer package use it and so I figured it would be okay?

    5.) Fixed, the trigger_error can now only be executed when in non-PEAR-mode. Again, if PEAR developers like yourself have considerable problems with this 'duality', let me know.

    6.) Agreed. I've implemented it with $iniSettings, and added a safe_mode check like you suggested.

    7.) Agreed. I've implemented it with setSigHandler()


    Further comments on for improvement are more than welcome.

    And if you (or anyone else) would like to discuss the implementation of a change in depth; please feel free to contact me on a messenger: http://kevin.vanzonneveld.net/about/. Of course, requests for changes themselves would have to be discusses in PEPR I think.

    (not a native English speaker so I hope everything is clear)