Page MenuHomestyx hydra

No OneTemporary

diff --git a/scripts/fpm/warmup.php b/scripts/fpm/warmup.php
new file mode 100644
index 0000000000..f4744d1991
--- /dev/null
+++ b/scripts/fpm/warmup.php
@@ -0,0 +1,54 @@
+<?php
+
+/*
+ * Copyright 2012 Facebook, Inc.
+ *
+ * Licensed under the Apache License, Version 2.0 (the "License");
+ * you may not use this file except in compliance with the License.
+ * You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+
+/**
+ * NOTE: This is an ADVANCED feature that improves performance but adds a lot
+ * of complexity! This is only suitable for production servers because workers
+ * won't pick up changes between when they spawn and when they handle a request.
+ *
+ * Phabricator spends a significant portion of its runtime loading classes
+ * and functions, even with APC enabled. Since we have very rigidly-defined
+ * rules about what can go in a module (specifically: no side effects), it
+ * is safe to load all the libraries *before* we receive a request.
+ *
+ * Normally, SAPIs don't provide a way to do this, but with a patched PHP-FPM
+ * SAPI you can provide a warmup file that it will execute before a request
+ * is received.
+ *
+ * We're limited in what we can do here, since request information won't
+ * exist yet, but we can load class and function definitions, which is what
+ * we're really interested in.
+ *
+ * Once this file exists, the FCGI process will drop into its normal accept loop
+ * and eventually process a request.
+ */
+function __warmup__() {
+ $root = dirname(dirname(dirname(dirname(__FILE__))));
+ require_once $root.'/libphutil/src/__phutil_library_init__.php';
+ require_once $root.'/arcanist/src/__phutil_library_init__.php';
+ require_once $root.'/phabricator/src/__phutil_library_init__.php';
+
+ // Load every symbol. We could possibly refine this -- we don't need to load
+ // every Controller, for instance.
+ $loader = new PhutilSymbolLoader();
+ $loader->selectAndLoadSymbols();
+
+ define('__WARMUP__', true);
+}
+
+__warmup__();
diff --git a/src/aphront/console/plugin/request/DarkConsoleRequestPlugin.php b/src/aphront/console/plugin/request/DarkConsoleRequestPlugin.php
index d4d17c394b..7e4ee4a8fd 100644
--- a/src/aphront/console/plugin/request/DarkConsoleRequestPlugin.php
+++ b/src/aphront/console/plugin/request/DarkConsoleRequestPlugin.php
@@ -1,79 +1,84 @@
<?php
/*
* Copyright 2012 Facebook, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
/**
* @group console
*/
final class DarkConsoleRequestPlugin extends DarkConsolePlugin {
public function getName() {
return 'Request';
}
public function getDescription() {
return 'Information about $_REQUEST and $_SERVER.';
}
public function generateData() {
return array(
'Request' => $_REQUEST,
'Server' => $_SERVER,
);
}
public function render() {
$data = $this->getData();
$sections = array(
'Basics' => array(
- 'Host' => $data['Server']['SERVER_ADDR'],
- 'Hostname' => gethostbyaddr($data['Server']['SERVER_ADDR']),
'Machine' => php_uname('n'),
),
);
+ // NOTE: This may not be present for some SAPIs, like php-fpm.
+ if (!empty($data['Server']['SERVER_ADDR'])) {
+ $addr = $data['Server']['SERVER_ADDR'];
+ $sections['Basics']['Host'] = $addr;
+ $sections['Basics']['Hostname'] = @gethostbyaddr($addr);
+ }
+
$sections = array_merge($sections, $data);
$out = array();
foreach ($sections as $header => $map) {
$rows = array();
foreach ($map as $key => $value) {
$rows[] = array(
phutil_escape_html($key),
phutil_escape_html(is_array($value) ? json_encode($value) : $value),
);
}
$table = new AphrontTableView($rows);
$table->setHeaders(
array(
$header,
null,
));
$table->setColumnClasses(
array(
'header',
'wide wrap',
));
$out[] = $table->render();
}
return implode("\n", $out);
}
}

File Metadata

Mime Type
text/x-diff
Expires
Fri, Nov 14, 2:02 AM (20 h, 35 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
336701
Default Alt Text
(4 KB)

Event Timeline