Skip to content

Instantly share code, notes, and snippets.

@briantully
Forked from tylers-username/.env
Created June 3, 2020 15:11
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save briantully/99bd450684ae8c1d7b29d9ea7e545379 to your computer and use it in GitHub Desktop.
Save briantully/99bd450684ae8c1d7b29d9ea7e545379 to your computer and use it in GitHub Desktop.
Install Blackfire on Lando & Automatically Configure
####
## Blackfire config - `lando rebuild` required
####
BLACKFIRE_CLIENT_ID=b5ee8ca3-****-****-****-5d227546a4c0
BLACKFIRE_CLIENT_TOKEN=3a2b88cbfb*******************************22763
BLACKFIRE_SERVER_ID=4b8ac335-****-****-****-b34439207732
BLACKFIRE_SERVER_TOKEN=98f7fdf4b12b7**************************12b837cf080d
name: my-php-project
services:
appserver:
type: php:7.0
via: nginx:1.13
ssl: true
webroot: pub
config:
# This provides our Blackfire environment credentials to PHP
conf: php.ini
build_as_root:
# Path to blackfireInit.sh
- ./blackfireInit.sh
tooling:
blackfire:
service: appserver
user: root
blackfire-agent:
service: appserver
user: root
blackfire-agent:service:
description: Start/Stop/Restart Blackfire agent service
cmd:
- /etc/init.d/blackfire-agent
service: appserver
user: root
#!/usr/bin/env bash
# Configure Blackfire Repository
wget -q -O - https://packages.blackfire.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
# Install Blackfire Agent
apt-get install blackfire-agent -y
printf "%s\n" $BLACKFIRE_CLIENT_ID $BLACKFIRE_CLIENT_TOKEN | blackfire config
# Start blackfire on-boot
/etc/init.d/blackfire-agent restart
# 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
# 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}"
@briantully
Copy link
Author

briantully commented Jun 3, 2020

From tylerssn:

Update (Apr 22, 2020): Made compatible with Lando v3.0.0-rcc3

Notes

  • Modifications to .env (or whichever env file your Lando uses) will not be merged into the Lando environment variables until lando rebuild is executed
  • It may be necessary to run lando blackfire-agent:service start after the initial rebuild

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment