Commit 0b0fc0d4 authored by Adrian Rossouw's avatar Adrian Rossouw Committed by adrian

Remove the provision cron and provision update commands, since we now use the...

Remove the provision cron and provision update commands, since we now use the ones provided by drush. Clean up the deploy process and document it more cleanly
parent 966c7493
<?php
/**
* Provision cron command
*/
function provision_drupal_provision_cron_verify() {
_provision_drupal_url_required();
_provision_drupal_valid_installed_site();
}
/**
* Drush command to run cron
*/
function _provision_cron($url) {
_provision_drupal_rebuild_caches($url);
}
<?php
/**
* Restore command implementation
* Deploy command implementation
*
* This command when called will
* 1. Make a backup of the current site, before modifications are made.
* 2. Temporarily disable the site by causing apache to redirect to a help page. Restarting apache is required.
* 3. Extract the backup that is being deployd to to a temporary folder in the sites directory.
* 4. Create a new database, belonging to the site's user, and switch it around with the current site's database.
* 5. Import the old database and site.php details.
* 6. Switch around the sites directory of the current site and the backup being deployd.
* 7. Regenerate configuration files.
* 8. TODO: diagnostic to test that everything is ok?
* 9. Remove the temporary redirect and restart apache so the previous site is available again.
* 10. Remove the extranuous db and duplicate site directory.
*
* If at any time an error occurs, before step 9. It should reverse all the changes it has made,
* and leave the current site directory and database in the right place, and remove all cruft that
* was created by this process.
* 1. Extract the backup that is being deployed to the target folder in the sites directory.
* 2. Import the drushrc.php details.
* 3. Do some diagnostics to make sure all the needed packages are available.
* 4. Create a new database, belonging to the site's user, and import the database dump.
* 5. Regenerate configuration files to show new db settings.
* 6. Call the drush 'updatedb' command to update the database if neccesary.
* 7. Update the file paths to the new sites directory.
* 8. Rebuild the site's package manifest.
* 9. Save the new drushrc.php with the newly generated settings.
*/
/**
......@@ -77,24 +72,19 @@ function provision_drupal_pre_provision_deploy($url, $backup_file) {
* Remove the extracted site directory
*/
function provision_drupal_pre_provision_deploy_rollback($url) {
_provision_recursive_delete(drush_get_option('sites_path') ."/$url");
}
/**
* Switch the deploy directories around now that we have the new db installed
*/
function provision_drupal_provision_deploy($url) {
// make sure it has the latest site data available
_provision_drupal_create_settings_file($url);
if ($site_root = drush_get_context('DRUSH_DRUPAL_SITE_ROOT')) {
_provision_recursive_delete($site_root);
}
}
// Luckily this is reversable =)
function provision_drupal_provision_deploy_rollback($url) {
provision_drupal_provision_deploy($url);
}
function provision_drupal_post_provision_deploy($url) {
drush_invoke('provision update', $url);
drush_include_engine('drupal', 'deploy');
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
_provision_drupal_create_settings_file($url);
// call the drush updatedb command.
drush_backend_invoke("updatedb", array('uri' => "http://$url"));
// We should be able to fully load Drupal now.
if (drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_FULL)) {
drush_include_engine('drupal', 'deploy');
drush_set_option('packages', _scrub_object(provision_drupal_system_map()), 'site');
}
}
<?php
function provision_drupal_provision_update_validate() {
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
}
function provision_drupal_provision_update($url) {
_provision_drupal_create_settings_file($url);
drush_backend_invoke("updatedb", array('uri' => "http://$url"));
drush_bootstrap(DRUSH_BOOTSTRAP_DRUPAL_SITE);
# drush_include_engine('drupal', 'update');
# drush_include_engine('drupal', 'clear');
}
......@@ -22,11 +22,10 @@
* or used for an upgrade.
* disable - Disable an installed Drupal site. Changes the virtual host config file so that it redirects to provision_disabled_site_redirect_url
* enable - Re-enable a site that has already been disabled. Recreates the virtual host file.
* delete - Generates a back up of the site, and then removes all references to it.
* delete - Generates a back up of the site, and then removes all references to it.
* restore - Revert to a previous backup of the site.
* cron - Run cron process for a site
*
* upgrade - Accepts a site package (backup) as argument, and redeploys it, running the upgrade processes on it.
* deploy - Accepts a site package (backup) as argument, and redeploys it, running the upgrade processes on it.
* Uses hook_provision_pre_upgrade(), hook_provision_upgrade() and hook_provision_post_upgrade() hooks,
* and allows clean roll back if any errors occur. Will include stringent checking of module versions,
* and allow unit tests to be run.
......@@ -64,12 +63,6 @@ function provision_drush_command() {
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision update'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to update.')),
'description' => dt('Run any outstanding updates on the site.'),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision backup'] = array(
'arguments' => array('domain.com' => dt('The domain of the site to back up.')),
'optional arguments' => array('backup-file' => dt('The file to save the backup to. This will be a gzipped tarball.')),
......@@ -120,11 +113,6 @@ function provision_drush_command() {
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
$items['provision cron'] = array(
'description' => 'Run cron process for site.',
'arguments' => array('domain.com' => dt('The domain of the site to be processed')),
'bootstrap' => DRUSH_BOOTSTRAP_DRUPAL_ROOT
);
return $items;
}
......
<?php
/**
* Implementation of hook_provision_pre_deploy
*/
function provision_apache_pre_provision_deploy($url = NULL) {
_provision_apache_create_vhost_config($url);
}
function provision_apache_pre_provision_deploy_rollback($url = NULL) {
_provision_apache_delete_vhost_config($url);
}
function provision_apache_post_provision_deploy($url = NULL) {
_provision_apache_create_vhost_config($url);
_provision_apache_restart_apache();
}
// The old db details should have been switched back by the mysql rollback at this point.
/**
* Delete the config file created.
*/
function provision_apache_post_provision_deploy_rollback($url = NULL) {
provision_apache_post_provision_deploy($url);
_provision_apache_delete_vhost_config($url);
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment