180 likes | 290 Views
Optimize Site Deployments with Drush. Saturday, 2011.11.12 – Drupal Camp Toronto 2011 Jon Peck, Owner, FluxSauce.com Audience: Intermediate. Revision 2. Who am I?. Jon Peck Founded web application development firm FluxSauce Zend Certified PHP Engineer Web development since 1998
E N D
Optimize Site Deployments with Drush Saturday, 2011.11.12 – Drupal Camp Toronto 2011 Jon Peck, Owner, FluxSauce.com Audience: Intermediate Revision 2.
Who am I? • Jon Peck • Founded web application development firm FluxSauce • ZendCertified PHP Engineer • Web development since 1998 • Used Drupal for the last three years
Overview • Why should you script site deployments? • What are drush and drush make, and how can you use them? • What are features, and does it fit your needs? • What are some recommended site deployment strategies? • How can you develop your own strategy?
Why script site deployments? • Reliability • Track changes over time (including blame) • Support multiple tiers • Manage and optimize your operations "Aaahhh!!!", CC BY 2.0 by Evil Erin @ flickr
What is drush? drushis a command line shell and scripting interface for Drupal.
What can you use drush for? • Manage modules • Manage users • Execute Drupal commands • Manipulate and extract site variables • Execute MySQL queries using Drupal config
What is drush make? A standard recipe for downloading everything you need for a site installation.
Three steps for deployment • Get the files (drush make)drush-y make --no-patch-txt "PATH/drush.make" FOLDER • 2. Install and configure (drush)cd FOLDERdrush-y site-install --config="PATH/drushrc.ENV.php” • 3. Enable modules (drush)drush-y en \admin_menu\ctools \...
Scripting site deployments • Drupal Deployment Skeleton (MIT license) • http://goo.gl/09JkE (gitHub) • /projects/NAME/config- stored in repository • drush.*.php • drush.make • config.ini • install.sh • setup.sh • rebuild.sh
What can you use features for? • Within your site (GUI) • Leveraging drush (command line)
What are features’ limitations? • Imperfect exports • No site variables without third-party modules • No theme, block support • No control logic • If you can't do it in the GUI... "40+296 Hello?", CC BY 2.0 by Bark @ flickr
Custom modules for granular control With hook_install(), you can programmatically… • Create users, roles, permissions • Create and hide blocks • Create content (nodes) • Import content types / CCK • Create vocabularies and terms (fields) • Set site variables (drushvget) • Import views
Custom module “gotchas” • Custom modules used like this need a user associateddrush-u 1 -y en custom_module • Clear all caches after installing your custom moduledrushcc all • Changes and updates need to go in hook_update_N within your module
Deployment strategies • Store everything in a versioning system • Always backup both your scripts and database first! • Tiered development strategy • Unique database credentials for each tier • When in doubt, rebuild on devfirst • Instead of repeating steps, do it in code • Document the process
How can I do this? • Get drush • Get drush_make • Define your needs. • Build and document your module toolbox • Start small, then scale up
"Question mark in Esbjerg", CC BY-SA 2.0 by Alexander Drachmann @ flickr Questions? Note: I have not used these techniques with Apache Ant or phpUnderControl.
Thank you! • drush • http://drupal.org/project/drush • drush_make • http://drupal.org/project/drush_make • Drupal Deployment Skeleton (DDS) • http://goo.gl/09JkE (gitHub) • drush make Generator • http://drushmake.me • permissions_api • http://drupal.org/project/permissions_api • Traditional Development... Practice for Software Development • http://dltj.org/article/software-development-practice jpeck@fluxsauce.com@FluxSaucehttp://fluxsauce.com