Skip to content

Instantly share code, notes, and snippets.

@philsturgeon
Created May 6, 2011 11:00
Show Gist options
  • Save philsturgeon/958755 to your computer and use it in GitHub Desktop.
Save philsturgeon/958755 to your computer and use it in GitHub Desktop.
Cells Processor for Fuel
<?php
/**
* Fuel
*
* Fuel is a fast, lightweight, community driven PHP5 framework.
*
* @package Fuel
* @version 1.0
* @author Fuel Development Team
* @license MIT License
* @copyright 2010 - 2011 Fuel Development Team
* @link http://fuelphp.com
*/
namespace Fuel\Tasks;
/**
* Queue Processor
*
* @package Fuel
* @version 1.0
* @author Phil Sturgeon
*/
class Process {
private static $tmp_path = '/tmp/';
public static function run()
{
$queue = \Model_Queue::find('all', array('related' => array('cell')));
foreach ($queue as $job)
{
# Clone git, including any random submodules
passthru('
cd '.static::$tmp_path .'
git clone --recursive "'.$job->cell->repository_url.'" "'.static::$tmp_path.$job->cell->name.'-'.$job->version.'/"
cd "'.static::$tmp_path.$job->cell->name.'-'.$job->version.'/"
# Kill of the .git folder and any random git bits, we dont need it
rm -rf ./.git ./.git*
# Remove this zip, if it is there, in case were wiping over
rm -rf "'.static::$tmp_path.$job->cell->name.'/'.$job->version.'.zip"
# Make the folder for this cell (will just bitch if already exists)
mkdir '.static::$tmp_path.$job->cell->name.'
# Zip it in place
zip -r "'.static::$tmp_path.$job->cell->name.'/'.$job->version.'" *
# Kill original folder
rm -rf "'.$job->cell->repository_url.'" "'.static::$tmp_path.$job->cell->name.'-'.$job->version.'/"
');
$job->delete();
}
}
}
/* End of file tasks/robots.php */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment