echo "[Thread-MASTER] Spawning new thread.  Still have " . count($groupList) . " group(s) to update after this\n";
            $ps->spawnThread();
        } else {
            // There are no more slots available to run
            //$ps->tick();
            //echo ".\n";
        }
    } else {
        // No more groups to process
        echo "No more groups to process - Initiating shutdown\n";
        $ps->Shutdown();
        echo "Shutdown complete\n";
    }
}
unset($groupList);
if ($ps->RunThreadCode()) {
    $group = $ps->threadData;
    $thread = sprintf("%05d", $ps->GetPID());
    echo "[Thread-{$thread}] Begining backfill processing for group {$group['name']}\n";
    $param = $group['name'];
    $dir = dirname(__FILE__);
    $file = 'backfill.php';
    $output = shell_exec("php {$dir}/{$file} {$param}");
    //$output = shell_exec("/usr/bin/php -c /etc/php5/cli/php.ini {$dir}/{$file} {$param}");
    echo "[Thread-{$thread}] Completed update for group {$group['name']}\n";
}
// Exit to call back to parent - Let know that child has completed
exit(0);
// Create callback function
function psUpdateComplete()
{
// Write some stuff to the log file
$pp->Log("Greetings! I am a Daemon example!");
$pp->Log("My PID is " . $pp->GetPID());
$pp->Log("I am going to write some stuff to a file now.");
// Echo this so the user can see that the daemon is starting
// The echo lines will go to STOUT instead of the log file
echo "Daemon started with 2 threads...\n";
echo "You can run `tail -f daemonlog.txt` to follow my progress...\n";
// Generate some fake data
$data = array(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15);
// Start the control loop
while ($pp->RunControlCode()) {
    // Check for data in the queue
    if (count($data)) {
        // Check if we can spawn
        if ($pp->SpawnReady()) {
            // Spawn a new thread
            $pp->SpawnThread('Thread-' . array_shift($data));
        }
    } else {
        // No more data - shutdown
        $pp->Shutdown();
        $pp->Log("The daemon is now exiting...");
    }
}
// Start the thread code
if ($pp->RunThreadCode()) {
    // Just write some stuff and sleep
    $pp->Log("This is " . $pp->WhoAmI() . " just saying hello world! Now to sleep for 5 seconds");
    sleep(5);
}