Skip to content

Instantly share code, notes, and snippets.

@jleehr
Last active June 8, 2021 13:43
Show Gist options
  • Save jleehr/554b46bdf584a86fa84732e725704067 to your computer and use it in GitHub Desktop.
Save jleehr/554b46bdf584a86fa84732e725704067 to your computer and use it in GitHub Desktop.
Blackfire.io & Lando
####
## Blackfire config - `lando rebuild` required
####
BLACKFIRE_CLIENT_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
BLACKFIRE_CLIENT_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
BLACKFIRE_SERVER_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxx
BLACKFIRE_SERVER_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
...
config:
config:
php: ./.lando/php.ini
...
services:
appserver:
build_as_root:
- ./.lando/blackfireInit.sh
run_as_root:
- service blackfire-agent start
...
tooling:
blackfire:
service: appserver
user: root
blackfire-agent:
cmd:
- blackfire agent:start
service: appserver
user: root
blackfire-agent:start:
description: Start Blackfire agent service
cmd:
- service blackfire-agent start
service: appserver
user: root
blackfire-agent:stop:
description: Stops Blackfire agent service
cmd:
- service blackfire-agent stop
service: appserver
user: root
blackfire-agent:restart:
description: Restart Blackfire agent service
cmd:
- service blackfire-agent restart
service: appserver
user: root
...
env_file:
- ./.lando/.blackfire.env

Blackfire.io with Lando

Usage

  • Put changes to your .lando.yml
  • Put all other files to ./.lando/
  • Make the .sh file executable chmod +x .lando/blackfireInit.sh

Best Practices

  • Disable xdebug at .lando.yml for profiling.
  • Run lando blackfire-agent:service start after the initial rebuild.
#!/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 install blackfire -y
blackfire agent:config --server-id=$BLACKFIRE_SERVER_ID --server-token=$BLACKFIRE_SERVER_TOKEN
# Start blackfire on-boot
service blackfire-agent restart
# Install Blackfire Probe
apt install blackfire-php -y
# Enable Blackfire Probe
docker-php-ext-enable blackfire
[xdebug]
xdebug.remote_autostart=0
xdebug.remote_enable=0
xdebug.profiler_enable=0
[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}"/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}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment