Location: PHPKode > scripts > NabiCI > CI/Continuous_integration.php
<?php

require_once realpath(dirname(__FILE__))."/".('Loop.php');
require_once realpath(dirname(__FILE__))."/".('website_builder.php');
require_once realpath(dirname(__FILE__))."/".('../include/read_ini_file.php');
define ("stop_ci","stop_ci.lock");
define("build_lock","build.lock");

/**
 * class Continuous_integration prepares all necessary steps to
 * run and finish a Loop and checks the feasibilty to run a Loop
 * 
 * @author Derya Oez
 * @version 1.0
 * @package NabidooCI
 */

class Continuous_integration
{
	
	/**
	 * function __construct($name) checks if a Loop is already running or not, locks for other Loops 
	 * to run the current Loop till finishing, gets all Information about the Loop from the configuration file,
	 * initializes to run the Continuous Integration Loop, unlocks after finishing Loop
	 * 
	 * @access public
	 * @param String $name  
	 * Instruction to run this Continuous Integration Loop
	 */

	public function __construct($name)
	{	
		//checking, if a loop is already running
		//if a loop is not running
		if (! easy_file::exists(build_lock))
		{	
			echo "starting with loop $name\n";
			//create a file named build.lock
			easy_file::write(build_lock,"");
			//get all Information from the configuration file, save as an Array
			$ini_array = read_ini_file("ci.ini");
			//creating an Object of Loop
			$loopObject  = new  Loop($name);
			//use the function run from the class loop to run
			$loopObject->run($ini_array);
			//checking, if the file stop_ci.lock exists 
			if (! easy_file::exists(stop_ci))
			{	//if stop_ci.lock does not exist, 
				//delete the build.lock file to unlock, so it´s possible to run another Loop 
				easy_file::delete(build_lock);
				echo "Loop $name finished.\n";
			}
			//if the stop_ci.lock exists, it is not possible to unlock
			else {
				echo "build.lock could not be deleted. Loops are still blocked.\n";
			}
		// if the build.lock exists, so it could not be started another loop 
		}else{
			echo"There is already a Loop running.\n";
		}	
	}
}

?>
Return current item: NabiCI