Login   Register  
PHP Classes
elePHPant
Icontem

File: background.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of kirankrishnan  >  OSX Process  >  background.php  >  Download  
File: background.php
Role: Example script
Content type: text/plain
Description: Example Usage
Class: OSX Process
Run PHP scripts in parallel using the PHP command
Author: By
Last change:
Date: 2010-03-28 05:42
Size: 1,076 bytes
 

Contents

Class file image Download
<?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 ;




?>