Created
March 17, 2010 18:11
-
-
Save travail/335530 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| set_include_path(dirname(__FILE__) . '/../lib'); | |
| require_once('Parallel/Prefork.php'); | |
| main(); | |
| exit(); | |
| function main() | |
| { | |
| $pp = new Parallel_Prefork(array( | |
| 'max_workers' => 5, | |
| 'trap_signals' => array( | |
| SIGHUP => SIGTERM, | |
| SIGTERM => SIGTERM, | |
| ), | |
| )); | |
| while ($pp->signalReceived() !== SIGTERM) { | |
| loadConfig(); | |
| if ($pp->start()) { | |
| continue; | |
| } | |
| workChildren(); | |
| $pp->finish(); | |
| } | |
| $pp->waitAllChildren(); | |
| } | |
| function loadConfig() | |
| { | |
| echo "Load configuratioin\n"; | |
| } | |
| function workChildren() | |
| { | |
| for ($i = 1; $i <= 3; $i++) { | |
| echo "Sleep $i seconds\n"; | |
| sleep($i); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment