PHP Classes
Icontem

File: test.php


  Search   All class groups All class groups   Latest entries Latest entries   Top 10 charts Top 10 charts   Newsletter Newsletter   Blog Blog   Forums Forums   Help FAQ Help FAQ  
  Login   Register  
Recommend this page to a friend! ReTweet ReTweet Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Grigori Kochanov  >  Daemon Emulation  >  test.php  
File: test.php
Role: Example script
Content type: text/plain
Description: run this from the comand line
Class: Daemon Emulation
Create and manage daemon processes
 

Contents

Class file image Download
_____________________________________
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();

?>

 
  Advertise on this site Advertise on this site   Site map Site map   Statistics Statistics   Site tips Site tips   Privacy policy Privacy policy   Contact Contact  

For more information send a message to :
info at phpclasses dot org.
Copyright (c) Icontem 1999-2009 PHP Classes - PHP Class Scripts
  PHP Book Reviews - Reviews of books and other products