コード例 #1
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $database_dir = sfConfig::get('sf_data_dir');
     $default_updater_configuration_file = $database_dir . '/updater-configuration.xml';
     //create the mysql connection command
     $xml_updater_configuration = new \sfAltumoPlugin\Deployment\DatabaseUpdaterConfigurationFile($default_updater_configuration_file);
     $command = "mysql -u" . $xml_updater_configuration->getDatabaseUsername() . " -p" . $xml_updater_configuration->getDatabasePassword() . " -h" . $xml_updater_configuration->getDatabaseHostname() . " " . $xml_updater_configuration->getDatabaseName() . "\n";
     \Altumo\Utils\Shell::runWithPipedOutput($command);
 }
コード例 #2
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     //sfAltumoPlugin tests
     //$test_suite = new \Altumo\Test\TestSuite( __DIR__ . '/../../test' );
     //Project tests
     //$test_suite = new \Altumo\Test\TestSuite( __DIR__ . '/../../../../test' );
     $commands = array('./symfony propel:build-sql', './symfony propel:build-forms', './symfony propel:build-model', './symfony propel:build-filters', './symfony altumo:build-javascript-dependencies');
     foreach ($commands as $command) {
         \Altumo\Utils\Shell::runWithPipedOutput($command);
     }
 }
コード例 #3
0
 /**
  * This method updates the application by:
  * 
  *   - Pulling the latest copy from the default git remote
  *   - Clearing the cache
  *   - Doing a database build
  * 
  */
 public function update()
 {
     $old_pwd = getcwd();
     chdir($this->getProjectRoot());
     $commands = array('git pull', 'git submodule sync', 'git submodule update --init --recursive', $this->getProjectRoot() . '/htdocs/project/symfony cc', $this->getProjectRoot() . '/htdocs/project/symfony altumo:update-database update');
     foreach ($commands as $command) {
         echo $command . "\n";
         \Altumo\Utils\Shell::runWithPipedOutput($command);
         //`$command`;
     }
     chdir($old_pwd);
 }
コード例 #4
0
 /**
  * @see sfTask
  */
 protected function execute($arguments = array(), $options = array())
 {
     $database_dir = sfConfig::get('sf_data_dir');
     $default_updater_configuration_file = $database_dir . '/updater-configuration.xml';
     $bare_database_target = $arguments['bare-database-target'];
     $xml_updater_configuration = new \sfAltumoPlugin\Deployment\DatabaseUpdaterConfigurationFile($default_updater_configuration_file);
     $xml_updater_configuration->setDatabaseDirectory($database_dir);
     $bare_database_loader = new \sfAltumoPlugin\Deployment\BareDatabaseLoader($xml_updater_configuration);
     // First reload propel sql files
     $this->log("\nReloading Propel SQL files\n");
     \Altumo\Utils\Shell::runWithPipedOutput(sfConfig::get('sf_root_dir') . '/symfony propel:build-sql');
     // Load bare database
     $this->log("\nApplying to bare database\n");
     $commands_executed = $bare_database_loader->loadBareDatabase();
     foreach ($commands_executed as $command) {
         $this->logSection('sh', $command);
     }
     $this->log("\nA fresh Propel database has been loaded to the bare database.\n");
 }
コード例 #5
0
ファイル: WorkingTree.php プロジェクト: homer6/altumo
 /**
  * Updates submodules recursively
  * 
  * 
  * @param bool $quiet
  *   // Run command in quiet mode. (ommit output)
  * 
  * @return void
  */
 public static function updateSubmodulesRecursively($quiet = true)
 {
     $command = "git submodule" . self::getQuietFlag($quiet) . "update --recursive --init";
     \Altumo\Utils\Shell::runWithPipedOutput($command);
 }
コード例 #6
0
 /**
  * Applies a data update 
  * 
  * A data update can perform operations at the application level. They have
  * access to the same functionallity the application does. Data updates can 
  * be used to modify data at the ORM level, or perform other operations
  * conveniently from code.
  * 
  * @param string $hash                   //the commit hash of the delta
  * 
  * @throws \Exception
  *   // if the hash for the commit where the data update file was added cannot be found.
  */
 protected function applyDataUpdate($hash)
 {
     // Remember the current position of the working tree.
     $current_position = \Altumo\Git\Status::getCurrentBranch();
     // Get the hash where the file was auto-moved to its folder by the build system
     $autocommit_hash = \Altumo\Git\History::getCommitsAfterMatching("^Autocommit\\:\\smoving.*" . $hash, $hash);
     if (count($autocommit_hash) != 1) {
         throw new \Exception('Unable to find an Autocommit for hash \\"' . $hash . '\\"');
     }
     $autocommit_hash = reset(array_keys($autocommit_hash));
     // remember current pwd
     $old_pwd = getcwd();
     // Get working tree root path
     $root_path = realpath(\sfConfig::get('sf_root_dir') . '/../../');
     // Go to the commit where the data_update script was auto-committed
     \Altumo\Git\WorkingTree::checkout($autocommit_hash);
     // Update submodules
     chdir($root_path);
     \Altumo\Git\WorkingTree::updateSubmodulesRecursively();
     //determine the php script filename and ensure the file exists
     $php_filename = $this->getDatabaseUpdaterConfigurationFile()->getDatabaseDirectory() . '/data_updates/' . 'data_update_' . $hash . '.php';
     if (!file_exists($php_filename)) {
         throw new \Exception('Script File "' . $php_filename . '" does not exist.');
     }
     // Call the altumo:apply-data-update in a separate process
     $project_path = realpath(\sfConfig::get('sf_root_dir'));
     chdir($project_path);
     $command = "./symfony altumo:apply-data-update {$hash}";
     // execute command
     \Altumo\Utils\Shell::runWithPipedOutput($command);
     // return the tree to where it was before.
     \Altumo\Git\WorkingTree::checkout($current_position);
     // Update submodules
     chdir($root_path);
     \Altumo\Git\WorkingTree::updateSubmodulesRecursively();
     chdir($old_pwd);
     $this->getDatabaseUpdateLogFile()->addDataUpdate($hash);
 }
コード例 #7
0
ファイル: SystemProcess.php プロジェクト: homer6/altumo
 /**
  * Sends a SIGKILL (9) to the process_id (pid) given.
  * 
  * 
  * @param int $process_id    // system pid to kill
  * 
  * @returns true if process was killed, false otherwise.
  */
 public static function killProcess($process_id)
 {
     $process_id = \Altumo\Validation\Numerics::assertUnsignedInteger($process_id, '$process_id expects unsinged integer');
     $result = \Altumo\Utils\Shell::runWithPipedOutput("kill -9 {$process_id}");
     return $result == 0;
 }