Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 43 lines (33 sloc) 1.205 kb
0b4173c @jestep First Commit php-multi-process 1.1
authored
1 <?php
2
3 require_once('lib/mp_config.php');
4 require_once('lib/mp_parent.class.php');
5
6 /**
e8abc0f @jestep Updated Passing Variables
authored
7 * Add an array to the $processes array for each child
8 * The processes array is an associative array('path'=>'filename.php','variables'=>array());
9 * You can add variables to send to the process through the same array
2697d58 @jestep Version 1.1.1
authored
10 * For some servers, you will need to enter the full path for each child (Ex: /home/myuser/public_html/processes/process_1.php)
0b4173c @jestep First Commit php-multi-process 1.1
authored
11 */
7de6743 @jestep Version 1.1
authored
12
e8abc0f @jestep Updated Passing Variables
authored
13 $processes[] = array('path'=>'process_1.php',
14 'variables'=>array('some_value'=>5,
15 'another_value'=>10)
16 );
17
18 $processes[] = array('path'=>'process_2.php',
19 'variables'=>array('other_value'=>7,
20 'get'=>$_GET)
21 );
0b4173c @jestep First Commit php-multi-process 1.1
authored
22
23 $mp = new multi_process();
24 $mp->createChildren($processes);
25
26 /**
27 * Reset the time limit after we spawn our background processes
def1f8f @jestep Version 1.1
authored
28 * Add 5 seconds total so that the children always timeout first
29 * Worst case should only take a few milliseconds once the children are finished
0b4173c @jestep First Commit php-multi-process 1.1
authored
30 */
7de6743 @jestep Version 1.1
authored
31
e8abc0f @jestep Updated Passing Variables
authored
32 ini_set("max_execution_time",DEFAULT_TIMELIMIT+5);
0b4173c @jestep First Commit php-multi-process 1.1
authored
33
34 $mp->checkStatus();
35
f56d3d3 @jestep Version 1.1
authored
36 /**
def1f8f @jestep Version 1.1
authored
37 * Here you can get the output from the children
f56d3d3 @jestep Version 1.1
authored
38 * $output = $mp->returnOutput();
39 *
def1f8f @jestep Version 1.1
authored
40 * @return array((int),(string)); --array('child_id','output');
f56d3d3 @jestep Version 1.1
authored
41 */
42
0b4173c @jestep First Commit php-multi-process 1.1
authored
43 $mp->cleanup();
Something went wrong with that request. Please try again.