[ Index ]

PHP Cross Reference of Phabricator

title

Body

[close]

/scripts/fpm/ -> warmup.php (source)

   1  <?php
   2  
   3  /**
   4   * NOTE: This is an ADVANCED feature that improves performance but adds a lot
   5   * of complexity! This is only suitable for production servers because workers
   6   * won't pick up changes between when they spawn and when they handle a request.
   7   *
   8   * Phabricator spends a significant portion of its runtime loading classes
   9   * and functions, even with APC enabled. Since we have very rigidly-defined
  10   * rules about what can go in a module (specifically: no side effects), it
  11   * is safe to load all the libraries *before* we receive a request.
  12   *
  13   * Normally, SAPIs don't provide a way to do this, but with a patched PHP-FPM
  14   * SAPI you can provide a warmup file that it will execute before a request
  15   * is received.
  16   *
  17   * We're limited in what we can do here, since request information won't
  18   * exist yet, but we can load class and function definitions, which is what
  19   * we're really interested in.
  20   *
  21   * Once this file exists, the FCGI process will drop into its normal accept loop
  22   * and eventually process a request.
  23   */
  24  function __warmup__() {
  25    $root = dirname(dirname(dirname(dirname(__FILE__))));
  26    require_once $root.'/libphutil/src/__phutil_library_init__.php';
  27    require_once $root.'/arcanist/src/__phutil_library_init__.php';
  28    require_once $root.'/phabricator/src/__phutil_library_init__.php';
  29  
  30    // Load every symbol. We could possibly refine this -- we don't need to load
  31    // every Controller, for instance.
  32    $loader = new PhutilSymbolLoader();
  33    $loader->selectAndLoadSymbols();
  34  
  35    define('__WARMUP__', true);
  36  }
  37  
  38  __warmup__();


Generated: Sun Nov 30 09:20:46 2014 Cross-referenced by PHPXref 0.7.1