0

I currently use drush alot to manage my sites, but I was wondering if there was a way to skip bootstrapping drupal everytime drush is run for certain commands that might not need it. This would save significant load time. I tend to do pm-list alot, but sometimes it just takes a long time to load depending on the size of the site. Same goes for enabling/disabling modules.

2

That is hard-coded for each command: The module defining a Drush command sets the bootstrap level required to run the command. For example, cache_drush_command() defines cache-clear as the following:

  $items['cache-clear'] = array(
    'bootstrap' => DRUSH_BOOTSTRAP_MAX, 
    'description' => 'Clear a specific cache, or all drupal caches.', 
    'arguments' => array(
      'type' => 'The particular cache to clear. Omit this argument to choose from available caches.',
    ), 
    'callback' => 'drush_cache_command_clear', 
    'aliases' => array('cc'),
  );

To require not bootstrap at all, the "bootstrap" property should be defined as follows.

  $items['xkcd-fetch'] = array(
    'description' => "Retrieve and display xkcd cartoons.", 
    'arguments' => array(
      'search' => 'Optional argument to retrive the cartoons matching an index number, keyword search or "random". If omitted the latest cartoon will be retrieved.',
    ), 
    'options' => array(
      'image-viewer' => 'Command to use to view images (e.g. xv, firefox). Defaults to "display" (from ImageMagick).', 
      'google-custom-search-api-key' => 'Google Custom Search API Key, available from https://code.google.com/apis/console/. Default key limited to 100 queries/day globally.',
    ), 
    'examples' => array(
      'drush xkcd' => 'Retrieve and display the latest cartoon.', 
      'drush xkcd sandwich' => 'Retrieve and display cartoons about sandwiches.', 
      'drush xkcd 123 --image-viewer=eog' => 'Retrieve and display cartoon #123 in eog.', 
      'drush xkcd random --image-viewer=firefox' => 'Retrieve and display a random cartoon in Firefox.',
    ), 
    'aliases' => array('xkcd'), 
    'bootstrap' => DRUSH_BOOTSTRAP_DRUSH, // No bootstrap at all.
  );

Using DRUSH_BOOTSTRAP_DRUSH says to Drush that Drupal doesn't need to be bootstrapped at all.

Clearly, that is not something that can be arbitrarily changed; it depends from the code executed from the command.

1
  • IOW, drush uses the minimal bootstrap necessary for the task it is trying to accomplish.
    – mpdonadio
    Mar 23 '13 at 20:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.