Location: PHPKode > scripts > Daemon Emulation > daemon-emulation/test.php
_____________________________________
to stop the process run
kill `cat daemon.pid`
_______________________________________
<?php
include 'daemon.class.php';

//N.B.: don't open the database connection before daemonizing
new Daemon();

for ($i=0;$i<3;++$i){
    echo 'script is using '.memory_get_usage()." bytes\n";
    $a[] = str_repeat('a',100000);
    sleep(1);
}

//terminate the daemon with 20% probability
(!mt_rand(0,5)) and Daemon::terminate();

?>
Return current item: Daemon Emulation