NYCPHP Meetup

NYPHP.org

[nycphp-talk] Writing daemons in PHP

Gary Mort garyamort at gmail.com
Thu Apr 7 17:38:10 EDT 2011


Just wondering what, in general, others are using for writing daemons in
PHP.

Just code it directly using libevent...   or using a framework such as
phpdaemon, https://github.com/kakserpom/phpdaemon


For a first pass, I need to set up a more intelligent CPULimit app to
meet my specific goals.  Since all CPULimit basically does is check all
the PID's every 2ms and send out kill to processes with SIGSTOP and
SIGCONT - it seems simple to do the same with PHP.

Just loop through every 2 ms and when cpu usage is over the threshold,
do some quick calcs to determine how many microseconds before the
processes can be continued in order to drop the cpu usage below the
threshold and use libevent to set the callback time.

Granted, this is supposedly "better" to program in C rather than PHP,
but since I want to be able to do quick changes and keep the learning
curve small, I'd rather do it in PHP until everything has been tweaked
and perfected.  Then it's always an option to try using HipHop to
convert it.... or if it is running well and doing what is needed, leave
it be.



More information about the talk mailing list