From 237db6cf91471d027ff4cd1b0bb469c5f75c1f3d Mon Sep 17 00:00:00 2001 From: Rob Bayliss Date: Tue, 26 May 2020 18:08:54 -0400 Subject: [PATCH] Use external blackfire agent, install only probe/cli on appserver --- .lando.yml | 23 ++++++++++++++++++----- .lando/config/php.ini | 28 ---------------------------- .lando/init/blackfire.sh | 27 +++++++-------------------- 3 files changed, 25 insertions(+), 53 deletions(-) delete mode 100644 .lando/config/php.ini diff --git a/.lando.yml b/.lando.yml index 191ca44..60493e5 100644 --- a/.lando.yml +++ b/.lando.yml @@ -16,14 +16,14 @@ services: appserver: build: - composer install - config: - conf: .lando/init/php.ini build_as_root: - .lando/init/terminus.sh - .lando/init/blackfire.sh - run_as_root: - # TODO: This doesn't seem to run at the correct time to ensure that blackfire-agent is running after a service rebuild. - - "/etc/init.d/blackfire-agent restart" + overrides: + environment: + BLACKFIRE_CLIENT_ID: + BLACKFIRE_CLIENT_TOKEN: + node: type: node build: @@ -35,6 +35,19 @@ services: services: image: devwithlando/php:7.3-apache command: docker-php-entrypoint /app/vendor/bin/mannequin start -c /app/.mannequin.php *:80 + blackfire: + type: compose + keys: false + app_mount: false + services: + image: "blackfire/blackfire" + user: root + command: blackfire-agent + environment: + BLACKFIRE_SERVER_ID: # Set in .env if you want to use Blackfire. + BLACKFIRE_SERVER_TOKEN: # Set in .env if you want to use Blackfire. + LANDO_DROP_USER: blackfire + tooling: gulp: service: node diff --git a/.lando/config/php.ini b/.lando/config/php.ini deleted file mode 100644 index f74e7ad..0000000 --- a/.lando/config/php.ini +++ /dev/null @@ -1,28 +0,0 @@ -# Blackfire Suggestions - -[blackfire] -; Enterprise does not have the option to update Blackfire settings via .platform.app.yaml -; We're giving ourselves auto-update capabilities here - -; Sets the socket where the agent is listening. -; Possible value can be a unix socket or a TCP address. -; Defaults to unix:///var/run/blackfire/agent.sock on Linux, -; unix:///usr/local/var/run/blackfire-agent.sock on MacOSX, -; and to tcp://127.0.0.1:8307 on Windows. -; blackfire.agent_socket = unix:///var/run/blackfire/agent.sock - -; Log verbosity level (4: debug, 3: info, 2: warning, 1: error) -; blackfire.log_level = 4 - -; Log file (STDERR by default) -; blackfire.log_file = "${LANDO_MOUNT}"/log/blackfire.log - -; Sets fine-grained configuration for Probe. -; This should be left blank in most cases. For most installs, -; the server credentials should only be set in the agent. -blackfire.server_id="${BLACKFIRE_SERVER_ID}" - -; Sets fine-grained configuration for Probe. -; This should be left blank in most cases. For most installs, -; the server credentials should only be set in the agent. -blackfire.server_token="${BLACKFIRE_SERVER_TOKEN}" diff --git a/.lando/init/blackfire.sh b/.lando/init/blackfire.sh index 8168197..873b2b8 100755 --- a/.lando/init/blackfire.sh +++ b/.lando/init/blackfire.sh @@ -1,23 +1,10 @@ #!/usr/bin/env bash +set -e -# Configure Blackfire Repository -wget -q -O - https://packagecloud.io/gpg.key | apt-key add - -echo 'deb http://packages.blackfire.io/debian any main' | tee /etc/apt/sources.list.d/blackfire.list -apt-get update +echo "Installing Blackfire PHP Probe..." +curl -o $(php -r "echo ini_get('extension_dir');")/blackfire.so -L -s https://packages.blackfire.io/binaries/blackfire-php/1.34.0/blackfire-php-linux_amd64-php-$(php -r "echo PHP_MAJOR_VERSION . PHP_MINOR_VERSION;").so +printf "extension=blackfire.so\nblackfire.agent_socket=tcp://blackfire:8707\n" > $PHP_INI_DIR/conf.d/blackfire.ini -# Install Blackfire Agent -apt-get --yes --force-yes install blackfire-agent -printf "%s\n" $BLACKFIRE_CLIENT_ID $BLACKFIRE_CLIENT_TOKEN | blackfire config - -# Install Blackfire Probe -version=$(php -r "echo PHP_MAJOR_VERSION.PHP_MINOR_VERSION;") -curl -A "Docker" -o /tmp/blackfire-probe.tar.gz -D - -L -s https://blackfire.io/api/v1/releases/probe/php/linux/amd64/$version -tar zxpf /tmp/blackfire-probe.tar.gz -C /tmp -mv /tmp/blackfire-*.so $(php -r "echo ini_get('extension_dir');")/blackfire.so - -# Enable Blackfire Probe -docker-php-ext-enable blackfire - -# Start blackfire on-boot -# TODO: this doesn't seem to run at the correct time to ensure that blackfire-agent is running when the service is rebuilt. -/etc/init.d/blackfire-agent restart +echo "Installing Blackfire CLI..." +curl -o /usr/local/bin/blackfire -L -s https://packages.blackfire.io/binaries/blackfire-agent/1.35.1/blackfire-cli-linux_static_amd64 +chmod +x /usr/local/bin/blackfire