Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Tideways with Xhgui #18

Merged
merged 88 commits into from Apr 1, 2019
Merged
Show file tree
Hide file tree
Changes from 29 commits
Commits
Show all changes
88 commits
Select commit Hold shift + click to select a range
dad8e64
working in progress
Mte90 Jul 5, 2018
bd116c9
added tideways
Mte90 Jul 5, 2018
49b574b
save also wordpress
Mte90 Jul 5, 2018
27a8f43
improvements
Mte90 Jul 6, 2018
785e39d
improvements
Mte90 Jul 6, 2018
8e819be
better organization
Mte90 Jul 6, 2018
927b146
improve detection of xhgui interfaces
Mte90 Jul 7, 2018
4e88094
fix path
Mte90 Jul 10, 2018
0dad4f8
nginx file
Mte90 Jul 12, 2018
9dc0109
better domain
Mte90 Jul 13, 2018
a38b19d
fix everything
Mte90 Jul 13, 2018
f677ca0
hosts support
Mte90 Jul 13, 2018
44fa3f0
append always hosts
Mte90 Jul 13, 2018
d1e7b30
added hosts
Mte90 Jul 13, 2018
f09ecf2
fix errors
Mte90 Jul 13, 2018
f2b9b46
right filename
Mte90 Jul 13, 2018
e75d1d8
Update provision.sh
Mte90 Jul 18, 2018
a839746
renamed file
Mte90 Jul 18, 2018
a7e1ebc
updates
Mte90 Aug 8, 2018
991ed11
alignment to latest changes on VVV
Mte90 Oct 23, 2018
50f46be
adding vvv-hosts file
Mte90 Oct 24, 2018
35fb48b
move vvv-hosts file
Mte90 Oct 24, 2018
0e1e04d
check if command exist
Mte90 Oct 24, 2018
4e880eb
improving paths
Mte90 Oct 24, 2018
6049a80
silemt output compiler
Mte90 Oct 24, 2018
13031b1
ready for testing
Mte90 Oct 24, 2018
671cb29
updated the domain used
tomjn Jan 14, 2019
8ce2eb5
Update vvv-hosts
tomjn Jan 14, 2019
640f86c
PHP 7.3 tideways support
tomjn Jan 14, 2019
f2885a6
force copy files in case they already exist
tomjn Jan 15, 2019
a334d7d
Fixed the DIR variable, the 0 parameter is always what was being ran,…
tomjn Jan 15, 2019
fb4fd3e
Simplify some parts, fix the detection of PHP versions, and some othe…
tomjn Jan 15, 2019
87f2e1f
removed vvv-hosts
Mte90 Jan 18, 2019
ce8bc8a
local aptkey
Mte90 Jan 18, 2019
2756c3e
local aptkey
Mte90 Jan 18, 2019
28c63e8
revert pwd because dirname is not working
Mte90 Jan 18, 2019
ac3753f
updated path
Mte90 Jan 18, 2019
6b589a0
updated path
Mte90 Jan 18, 2019
5fec39e
get the path
Mte90 Jan 18, 2019
de46e0d
fix the last 2 reported issue
Mte90 Jan 18, 2019
52197b4
bump php version for mongodb
Mte90 Jan 29, 2019
f161a8d
right parameters for ln
Mte90 Jan 29, 2019
2c6b5d3
install for various verison
Mte90 Feb 6, 2019
b7b322f
specify php version for phpenmod
Mte90 Feb 14, 2019
e4663df
specify php version for phpenmod
Mte90 Feb 14, 2019
6ec271d
linting
Mte90 Feb 14, 2019
23232c1
other fixes
Mte90 Feb 14, 2019
949330e
cleaning
Mte90 Feb 14, 2019
b39049e
optimize script
Mte90 Feb 14, 2019
1e51259
symlink to avoid issues with pecl
Mte90 Feb 14, 2019
4ef6575
reorganizing code
Mte90 Feb 14, 2019
7ee18d0
find workaround for pecl
Mte90 Feb 14, 2019
46603db
finally everything works!
Mte90 Feb 14, 2019
ac0b52a
moved mongodb as utility
Mte90 Feb 14, 2019
78389c5
moved mongodb as utility
Mte90 Feb 14, 2019
47b3b13
check if mongo is avalaible
Mte90 Feb 14, 2019
f519faf
missing permission execute to mongodb provision
Mte90 Mar 18, 2019
545b8c8
language and logging improvements
tomjn Mar 18, 2019
3bb58b6
added the xhgui.vvv.test domain to the nginx config
tomjn Mar 18, 2019
e324fea
Abort if mongodb isn't present, always install xhgui, and improve the…
tomjn Mar 18, 2019
7b64547
move the check if mongodb is installed to wrap around the install_mon…
tomjn Mar 19, 2019
43fbc6e
Try to provision mongodb if mongo is unavailable before setting up ti…
tomjn Mar 19, 2019
098b5fe
Unsilence the git clone of xhgui and fix mongodb provisioning
tomjn Mar 19, 2019
2850699
Fix xhgui cloning
tomjn Mar 19, 2019
8d0c471
always provision the xhgui nginx configs
tomjn Mar 19, 2019
0e7258c
remove log output
Mte90 Mar 19, 2019
86ad759
remove log output
Mte90 Mar 19, 2019
c274b12
migrate to package
Mte90 Mar 19, 2019
f4d4fe4
move also the php file
Mte90 Mar 19, 2019
ccf735a
command to load the new php settings
Mte90 Mar 19, 2019
3a7fd4a
fix bash
Mte90 Mar 19, 2019
c462dd6
install mongodb
Mte90 Mar 19, 2019
ab255a9
get right path for mongodb and fix for apt
Mte90 Mar 19, 2019
899ca57
revert back xhprof
Mte90 Mar 19, 2019
f6a2a11
revert also tidewais file
Mte90 Mar 19, 2019
c39800e
fix preped file
Mte90 Mar 19, 2019
083036d
avoid autoscan of xhgui
Mte90 Mar 19, 2019
0a46ed0
add custom files and settings
Mte90 Mar 20, 2019
72e21a8
not compile tideways if there aren't updates
Mte90 Mar 20, 2019
5efe38c
fix path in mongodb to test
Mte90 Mar 23, 2019
b1be987
reset path
Mte90 Mar 23, 2019
83145b4
disable query monitor on loading tideways
Mte90 Mar 26, 2019
b46c7c4
remove the parameter from the url in xhgui
Mte90 Mar 27, 2019
4d6f007
changes how/where/when copying of tideways-header.php happens
tomjn Apr 1, 2019
f60dbb7
only load /srv/www/default/xhgui/external/header.php if it exists
tomjn Apr 1, 2019
46db07f
updates the auto_prepend_file directive
tomjn Apr 1, 2019
c4fa3a9
Improve the mongodb provisioner
tomjn Apr 1, 2019
4d326ad
copy tideways header before handling PHP, and always copy certain fil…
tomjn Apr 1, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
28 changes: 28 additions & 0 deletions tideways/config.php
@@ -0,0 +1,28 @@
<?php

// In config/config.php
return array(
'debug' => false,

// Can be either mongodb or file.
'save.handler' => 'mongodb',

// Needed for file save handler. Beware of file locking. You can adujst this file path
// to reduce locking problems (eg uniqid, time ...)
//'save.handler.filename' => __DIR__.'/../data/xhgui_'.date('Ymd').'.dat',
'db.host' => 'mongodb://127.0.0.1:27017',
'db.db' => 'xhprof',

'templates.path' => dirname(__DIR__) . '/src/templates',
'date.format' => 'M jS H:i:s',
'detail.count' => 6,
'page.limit' => 25,
// Other config
'profiler.enable' => function() {
$url = $_SERVER['REQUEST_URI'];
if (strpos($url, '/xhgui/') === 0) {
return false;
}
return true;
}
);
1 change: 1 addition & 0 deletions tideways/mongodb.ini
@@ -0,0 +1 @@
extension=mongodb.so
22 changes: 22 additions & 0 deletions tideways/nginx.conf
@@ -0,0 +1,22 @@
server {
listen 80;
listen 443 ssl;
root /srv/www/default/xhgui/webroot;
index index.php;
server_name tideways.vvv.test;

gzip off;

location / {
try_files $uri $uri/ /index.php?$args;
}

location ~ \.php$ {
client_max_body_size 1024M;
try_files $uri =404;
include /etc/nginx/fastcgi_params;
fastcgi_pass php;
fastcgi_index index.php;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
}
}
125 changes: 125 additions & 0 deletions tideways/provision.sh
@@ -0,0 +1,125 @@
#!/usr/bin/env bash
# Tideways with XHgui
DIR=$(pwd)

install_tideways() {
# Tideways is only for php =>7.0
echo "Installing/update Tideways to PHP 7.0, 7.1, 7.2 7.3"
git clone "https://github.com/tideways/php-xhprof-extension" "/var/local/tideways-php7.2"
cp -r /var/local/tideways-php7.2 /var/local/tideways-php7.0
cp -r /var/local/tideways-php7.2 /var/local/tideways-php7.1
cp -r /var/local/tideways-php7.2 /var/local/tideways-php7.3
for version in 7.0 7.1 7.2 7.3
do
echo "Compiling Tideways for PHP $version"
cd "/var/local/tideways-php${version}"
update-alternatives --set php /usr/bin/php$version > /dev/null 2>&1
update-alternatives --set php-config /usr/bin/php-config$version > /dev/null 2>&1
update-alternatives --set phpize /usr/bin/phpize$version > /dev/null 2>&1
phpize$version
./configure --enable-tideways-xhprof --with-php-config=php-config$version > /dev/null 2>&1
make > /dev/null 2>&1
make install > /dev/null 2>&1
done
}

restart_php() {
if [[ -d "/etc/php/7.0/" ]]; then
service php7.0-fpm restart
fi
if [[ -d "/etc/php/7.1/" ]]; then
service php7.1-fpm restart
fi
if [[ -d "/etc/php/7.2/" ]]; then
service php7.2-fpm restart
fi
if [[ -d "/etc/php/7.3/" ]]; then
service php7.3-fpm restart
fi
}

install_mongodb() {
apt-key adv --keyserver hkp://keyserver.ubuntu.com:80 --recv 0C49F3730359A14518585931BC711F9BA15703C6
Mte90 marked this conversation as resolved.
Show resolved Hide resolved
echo "deb http://repo.mongodb.org/apt/ubuntu trusty/mongodb-org/3.4 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-3.4.list
sudo apt update > /dev/null 2>&1
apt-get -y install mongodb-org re2c
sudo pecl install mongodb
ln -s /usr/lib/php/20151012/mongodb.so /usr/lib/php/20170718/mongodb.so
ln -s /usr/lib/php/20160303/mongodb.so /usr/lib/php/20170718/mongodb.so
phpenmod mongodb
# auto-remove records older than 2592000 seconds (30 days)
mongo xhprof --eval 'db.collection.ensureIndex( { "meta.request_ts" : 1 }, { expireAfterSeconds : 2592000 } )' > /dev/null 2>&1
# indexes
mongo xhprof --eval "db.collection.ensureIndex( { 'meta.SERVER.REQUEST_TIME' : -1 } )" > /dev/null 2>&1
mongo xhprof --eval "db.collection.ensureIndex( { 'profile.main().wt' : -1 } )" > /dev/null 2>&1
mongo xhprof --eval "db.collection.ensureIndex( { 'profile.main().mu' : -1 } )" > /dev/null 2>&1
mongo xhprof --eval "db.collection.ensureIndex( { 'profile.main().cpu' : -1 } )" > /dev/null 2>&1
mongo xhprof --eval "db.collection.ensureIndex( { 'meta.url' : 1 } )" > /dev/null 2>&1
update-rc.d mongodb defaults
update-rc.d mongodb enable
Mte90 marked this conversation as resolved.
Show resolved Hide resolved
}

echo "Installing Tideways & XHgui"
if [[ ! -d "/srv/www/default/xhgui" ]]; then
if [[ -d "/etc/php/7.0/" ]]; then
echo "File copied for php 7.0"
cp "${DIR}/tideways.ini" "/etc/php/7.0/mods-available/tideways_xhprof.ini"
cp "${DIR}/mongodb.ini" "/etc/php/7.0/mods-available/mongodb.ini"
cp "${DIR}/xhgui-php.ini" "/etc/php/7.0/mods-available/xhgui.ini"
fi
if [[ -d "/etc/php/7.1/" ]]; then
echo "File copied for php 7.1"
cp "${DIR}/tideways.ini" "/etc/php/7.1/mods-available/tideways_xhprof.ini"
cp "${DIR}/mongodb.ini" "/etc/php/7.1/mods-available/mongodb.ini"
cp "${DIR}/xhgui-php.ini" "/etc/php/7.1/mods-available/xhgui.ini"
fi
if [[ -d "/etc/php/7.2/" ]]; then
echo "File copied for php 7.2"
cp "${DIR}/tideways.ini" "/etc/php/7.2/mods-available/tideways_xhprof.ini"
cp "${DIR}/xhgui-php.ini" "/etc/php/7.2/mods-available/xhgui.ini"
# For the default php version
cp "${DIR}/mongodb.ini" "/etc/php/7.2/mods-available/mongodb.ini"
fi
if [[ -d "/etc/php/7.3/" ]]; then
echo "File copied for php 7.3"
cp "${DIR}/tideways.ini" "/etc/php/7.3/mods-available/tideways_xhprof.ini"
cp "${DIR}/mongodb.ini" "/etc/php/7.3/mods-available/mongodb.ini"
cp "${DIR}/xhgui-php.ini" "/etc/php/7.3/mods-available/xhgui.ini"
fi
install_mongodb
install_tideways
phpenmod tideways_xhprof
echo -e "\nDownloading xhgui, see https://github.com/perftools/xhgui"
git clone "https://github.com/perftools/xhgui" "/srv/www/default/xhgui"
cd /srv/www/default/xhgui
php install.php > /dev/null 2>&1
cp "${DIR}/vvv-hosts" "/srv/www/default/xhgui/vvv-hosts"
Mte90 marked this conversation as resolved.
Show resolved Hide resolved
cp "${DIR}/config.php" "/srv/www/default/xhgui/config/config.php"
cp "${DIR}/tideways-header.php" "/srv/www/default/xhgui/config/tideways-header.php"
cp "${DIR}/nginx.conf" "/etc/nginx/custom-utilities/xhgui.conf"
restart_php
service mongodb restart
if [[ -d "/etc/php/7.0/" ]]; then
php7.0 --ri tideways_xhprof
fi
if [[ -d "/etc/php/7.1/" ]]; then
php7.1 --ri tideways_xhprof
fi
if [[ -d "/etc/php/7.3/" ]]; then
php7.3 --ri tideways_xhprof
fi
php --ri tideways_xhprof
else
echo -e "\nUpdating xhgui..."
cd /srv/www/default/xhgui
git pull --rebase origin master > /dev/null 2>&1
rm -rf /var/local/tideways-php7.0
rm -rf /var/local/tideways-php7.1
rm -rf /var/local/tideways-php7.2
rm -rf /var/local/tideways-php7.3
install_tideways
make > /dev/null 2>&1
make install > /dev/null 2>&1
restart_php
fi

6 changes: 6 additions & 0 deletions tideways/tideways-header.php
@@ -0,0 +1,6 @@
<?php

if(strpos($_SERVER['REQUEST_URI'], 'enable-tideways') !== false) {
include '/srv/www/default/xhgui/external/header.php';
}

1 change: 1 addition & 0 deletions tideways/tideways.ini
@@ -0,0 +1 @@
extension=tideways_xhprof.so
1 change: 1 addition & 0 deletions tideways/vvv-hosts
@@ -0,0 +1 @@
tideways.vvv.test
1 change: 1 addition & 0 deletions tideways/xhgui-php.ini
@@ -0,0 +1 @@
auto_prepend_file=/srv/www/default/xhgui/config/tideways-header.php