Add PHP-SPX profiling extension for development environment (#4032)

Co-authored-by: Buster "Silver Eagle" Neece <buster@busterneece.com>
This commit is contained in:
Vaalyn 2021-04-18 03:50:54 +02:00 committed by GitHub
parent 4e6f1d700c
commit 8f900af32f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 84 additions and 18 deletions

View File

@ -56,7 +56,9 @@ ENV LANG="en_US.UTF-8" \
MYSQL_DATABASE="azuracast" \
PREFER_RELEASE_BUILDS="false" \
COMPOSER_PLUGIN_MODE="false" \
ADDITIONAL_MEDIA_SYNC_WORKER_COUNT=0
ADDITIONAL_MEDIA_SYNC_WORKER_COUNT=0 \
PROFILING_EXTENSION_ENABLED=0 \
PROFILING_EXTENSION_ALWAYS_ON=0
# Entrypoint and default command
ENTRYPOINT ["/usr/local/bin/uptime_wait"]

View File

@ -63,3 +63,21 @@ MYSQL_SLOW_QUERY_LOG=1
# if you are seeing the `Too many connections` error in the logs.
# Default: 100
MYSQL_MAX_CONNECTIONS=100
# Enable the profiling extension.
# Profiling data can be viewed by visiting http://your-azuracast-site/?SPX_KEY=dev&SPX_UI_URI=/
# Default: 0
PROFILING_EXTENSION_ENABLED=1
# Profile ALL requests made to this account.
# This will have significant performance impact on your installation and should only be used in test circumstances.
# Default: 0
PROFILING_EXTENSION_ALWAYS_ON=0
# Configure the value for the SPX_KEY parameter needed to access the profiling dashboard
# Default: dev
PROFILING_EXTENSION_HTTP_KEY=dev
# Configure the IP whitelist for the profiling dashboard
# Default: *
PROFILING_EXTENSION_HTTP_IP_WHITELIST=*

View File

@ -128,3 +128,31 @@ MYSQL_MAX_CONNECTIONS=100
# by creating additional worker processes to consume messages
# Default: 0
# ADDITIONAL_MEDIA_SYNC_WORKER_COUNT=0
#
# PHP-SPX profiling extension Configuration
#
# These environment variables allow you to enable and configure the PHP-SPX profiling extension
# which can be helpful when debugging resource issues in AzuraCast.
#
# The profiling dashboard can be accessed by visting https://yourdomain.com/?SPX_KEY=dev&SPX_UI_URI=/
# If you change the PROFILING_EXTENSION_HTTP_KEY variable change the value for SPX_KEY accordingly.
#
# Enable the profiling extension.
# Profiling data can be viewed by visiting http://your-azuracast-site/?SPX_KEY=dev&SPX_UI_URI=/
# Default: 0
PROFILING_EXTENSION_ENABLED=1
# Profile ALL requests made to this account.
# This will have significant performance impact on your installation and should only be used in test circumstances.
# Default: 0
PROFILING_EXTENSION_ALWAYS_ON=0
# Configure the value for the SPX_KEY parameter needed to access the profiling dashboard
# Default: dev
# PROFILING_EXTENSION_HTTP_KEY=dev
# Configure the IP whitelist for the profiling dashboard
# Default: *
# PROFILING_EXTENSION_HTTP_IP_WHITELIST=*

View File

@ -2,12 +2,7 @@ version : '2.2'
services :
web :
image : azuracast_cli:latest
environment :
APPLICATION_ENV : 'testing'
build :
context : ./util/docker/testing
cache_from :
- azuracast/azuracast_web_v2:latest
volumes :
- .:/var/azuracast/www

View File

@ -1,9 +0,0 @@
FROM azuracast/azuracast_web_v2:latest
RUN apt-get update \
&& apt-get install -q -y php7.4-xdebug
ENV PATH="${PATH}:/var/azuracast/.composer/vendor/bin" \
APPLICATION_ENV="testing"
USER root

View File

@ -12,4 +12,16 @@ opcache.enable_cli=1
{{if eq .Env.APPLICATION_ENV "production"}}
opcache.revalidate_freq={{ default .Env.PHP_OPCACHE_REVALIDATE_FREQUENCY "60" }}
{{end}}
{{end}}
{{if eq .Env.PROFILING_EXTENSION_ENABLED "1"}}
spx.http_enabled=1
spx.data_dir=/var/azuracast/www_tmp
spx.http_key={{ default .Env.PROFILING_EXTENSION_HTTP_KEY "dev" }}
spx.http_ip_whitelist={{ default .Env.PROFILING_EXTENSION_HTTP_IP_WHITELIST "*" }}
zlib.output_compression=0
{{if eq .Env.PROFILING_EXTENSION_ALWAYS_ON "1"}}
spx.http_profiling_enabled=1
{{end}}
{{end}}

View File

@ -21,4 +21,8 @@ chdir = /
clear_env=No
catch_workers_output = yes
decorate_workers_output = no
decorate_workers_output = no
{{if eq .Env.PROFILING_EXTENSION_ENABLED "1"}}
process.dumpable = yes
{{end}}

View File

@ -9,7 +9,7 @@ apt-get update
$minimal_apt_get_install php7.4-fpm php7.4-cli php7.4-gd \
php7.4-curl php7.4-xml php7.4-zip php7.4-bcmath php7.4-gmp \
php7.4-mysqlnd php7.4-mbstring php7.4-intl php7.4-redis \
php7.4-maxminddb \
php7.4-maxminddb php7.4-xdebug \
mariadb-client
# Copy PHP configuration
@ -21,3 +21,19 @@ cp /bd_build/php/www.conf.tmpl /etc/php/7.4/fpm/www.conf.tmpl
# Install Composer
curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/bin --filename=composer
# Install PHP SPX profiler
$minimal_apt_get_install php7.4-dev zlib1g-dev build-essential
cd /bd_build
git clone https://github.com/NoiseByNorthwest/php-spx.git
cd php-spx
phpize
./configure
make
sudo make install
apt-get remove --purge -y php7.4-dev zlib1g-dev build-essential
echo "extension=spx.so" > /etc/php/7.4/cli/conf.d/30-spx.ini
echo "extension=spx.so" > /etc/php/7.4/fpm/conf.d/30-spx.ini