| 
<?php
include("Process.php");
 
 
 
 
 
 $dirname    =    dirname(__FILE__)."/stat/"; // working directory for storing  status and  files
 $fileToRun    =    dirname(__FILE__)."/demo.php"; // php script to run in background
 
 
 
 $obj =    new OSX_Process();
 $obj->setDir($dirname);
 
 //Create first process //
 $obj->setInstance(1000);
 $prcId1    =    $obj->runPhp($fileToRun,array("someValue"=>900));
 echo "Process Id - 1 ".$prcId1;
 if($obj->checkProcess($prcId1)){
 echo "Process 1 Running";
 print_r($obj->getStat());
 }else{
 echo " Process 1 Stopped ";
 }
 
 //create another process//
 $obj->setInstance(2000);
 $prcId2    =    $obj->runPhp($fileToRun,array("someValue"=>100));
 echo "Process Id - 2 ".$prcId2;
 if($obj->checkProcess($prcId2)){
 echo "Process 2 Running";
 print_r($obj->getStat());
 }else{
 echo " Process 2 Stopped ";
 }
 echo "Outfile".$obj->getOutFile();
 echo "Pidfile".$obj->getPidFile();
 
 
 echo "Killing processes";
 
 $obj->killProcess($prcId1,1000);
 $obj->killProcess($prcId2,2000);
 
 
 $obj->clear(); /// clear should be called at the end ;
 
 
 
 
 ?>
 |