• Stars
    star
    512
  • Rank 86,302 (Top 2 %)
  • Language
    Ruby
  • License
    MIT License
  • Created over 9 years ago
  • Updated 7 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Airbrussh pretties up your SSHKit and Capistrano output

Airbrussh

Gem Version Build Status Build status Code Climate Coverage Status

Airbrussh is a concise log formatter for Capistrano and SSHKit. It displays well-formatted, useful log output that is easy to read. Airbrussh also saves Capistrano's verbose output to a separate log file just in case you need additional details for troubleshooting.

As of April 2016, Airbrussh is bundled with Capistrano 3.5, and is Capistrano's default formatter! There is nothing additional to install or enable. Continue reading to learn more about Airbrussh's features and configuration options.

If you aren't yet using Capistrano 3.5 (or wish to use Airbrussh with SSHKit directly), refer to the advanced/legacy usage section for installation instructions.

Sample output

For more details on how exactly Airbrussh affects Capistrano's output and the reasoning behind it, check out the blog post: Introducing Airbrussh.


Usage

Airbrussh is enabled by default in Capistrano 3.5 and newer. To manually enable Airbrussh (for example, when upgrading an existing project), set the Capistrano format like this:

# In deploy.rb
set :format, :airbrussh

What's displayed

When you run a Capistrano command, Airbrussh provides the following information in its output:

Sample output

  • Name of Capistrano task being executed
  • When each task started (minutes:seconds elapsed since the deploy began)
  • The SSH command-line strings that are executed; for Capistrano tasks that involve running multiple commands, the numeric prefix indicates the command in the sequence, starting from 01
  • Stdout and stderr output from each command
  • The duration of each command execution, per server

What's not displayed

For brevity, Airbrussh does not show everything that Capistrano is doing. For example, it will omit Capistrano's test commands, which can be noisy and confusing. Airbrussh also hides things like environment variables, as well as cd and env invocations. To see a full audit of Capistrano's execution, including exactly what commands were run on each server, look at log/capistrano.log.

Configuration

You can customize many aspects of Airbrussh's output. In Capistrano 3.5 and newer, this is done via the :format_options variable, like this:

# Pass options to Airbrussh
set :format_options, color: false, truncate: 80

Here are the options you can use, and their effects (note that the defaults may be different depending on where Airbrussh is used; these are the defaults used by Capistrano 3.5):

Option Default Usage
banner nil Provide a string (e.g. "Capistrano started!") that will be printed when Capistrano starts up.
color :auto Use true or false to enable or disable ansi color. If set to :auto, Airbrussh automatically uses color based on whether the output is a TTY, or if the SSHKIT_COLOR environment variable is set.
command_output true Set to :stdout, :stderr, or true to display the SSH output received via stdout, stderr, or both, respectively. Set to false to not show any SSH output, for a minimal look.
context Airbrussh::Rake::Context Defines the execution context. Targeted towards uses of Airbrussh outside of Rake/Capistrano. Alternate implementations should provide the definition for current_task_name, register_new_command, and position.
log_file log/capistrano.log Capistrano's verbose output is saved to this file to facilitate debugging. Set to nil to disable completely.
truncate :auto Set to a number (e.g. 80) to truncate the width of the output to that many characters, or false to disable truncation. If :auto, output is automatically truncated to the width of the terminal window, if it can be determined.
task_prefix nil A string to prefix to task output. Handy for output collapsing like buildkite's --- prefix

FAQ

Airbrussh is not displaying the output of my commands! For example, I run tail in one of my capistrano tasks and airbrussh doesn't show anything. How do I fix this?

Make sure Airbrussh is configured to show SSH output.

set :format_options, command_output: true

I haven't upgraded to Capistrano 3.5 yet. Can I still use Airbrussh?

Yes! Capistrano 3.4.x is also supported. Refer to the advanced/legacy usage section for installation instructions.

Does Airbrussh work with Capistrano 2?

No, Capistrano 3 is required. We recommend Capistrano 3.4.0 or higher. Capistrano 3.5.0 and higher have Airbrussh enabled by default, with no installation needed.

Does Airbrussh work with JRuby?

JRuby is not officially supported or tested, but may work. You must disable automatic truncation to work around a known bug in the JRuby 9.0 standard library. See #62 for more details.

set :format_options, truncate: false

I have a question that’s not answered here or elsewhere in the README.

Please open a GitHub issue and we’ll be happy to help!

Advanced/legacy usage

Although Airbrussh is built into Capistrano 3.5.0 and higher, it is also available as a plug-in for older versions. Airbrussh has been tested with MRI 1.9+, Capistrano 3.4.0+, and SSHKit 1.6.1+.

Capistrano 3.4.x

Add this line to your application's Gemfile:

gem "airbrussh", require: false

And then execute:

$ bundle

Finally, add this line to your application's Capfile:

require "airbrussh/capistrano"

Important: explicitly setting Capistrano's :format option in your deploy.rb will override airbrussh. Remove this line if you have it:

# Remove this
set :format, :pretty

Capistrano 3.4.x doesn't have the :format_options configuration system, so you will need to configure Airbrussh using this technique:

Airbrussh.configure do |config|
  config.color = false
  config.command_output = true
  # etc.
end

Refer to the configuration section above for the list of supported options.

SSHKit

If you are using SSHKit directly (i.e. without Capistrano), you can use Airbrussh like this:

require "airbrussh"
SSHKit.config.output = Airbrussh::Formatter.new($stdout)

# You can also pass configuration options like this
SSHKit.config.output = Airbrussh::Formatter.new($stdout, color: false)

History

Airbrussh started life as custom logging code within the capistrano-mb collection of opinionated Capistrano recipes. In February 2015, the logging code was refactored into a standalone gem with its own configuration and documentation, and renamed airbrussh. In February 2016, Airbrussh was added as the default formatter in Capistrano 3.5.0.

Roadmap

Airbrussh now has a stable feature set, excellent test coverage, is being used for production deployments, and has reached 1.0.0! If you have ideas for improvements to Airbrussh, please open a GitHub issue.

Contributing

Contributions are welcome! Read CONTRIBUTING.md to get started.

More Repositories

1

rails-template

My former app template for Rails 7. All recommendations you see here have been moved to https://github.com/mattbrictson/nextgen
Ruby
1,084
star
2

tomo

A friendly and extensible CLI for deploying Rails apps via SSH
Ruby
379
star
3

bundleup

A friendlier CLI for Bundler’s `update` and `outdated` commands.
Ruby
194
star
4

chandler

[unmaintained] chandler syncs your CHANGELOG entries to GitHub's release notes
Ruby
152
star
5

nextgen

Generate your next Rails app interactively! This template includes production-ready recommendations for testing, security, developer productivity, and modern frontends. Plus optional Vite support! ⚡️
Ruby
132
star
6

capistrano-mb

[unmaintained] Capistrano tasks for deploying Rails from scratch to Ubuntu 16.04 and 18.04
Ruby
119
star
7

bundle_update_interactive

A stylish interactive mode for Bundler, inspired by `yarn upgrade-interactive`
Ruby
101
star
8

rails-starter

I've stopped maintaining this project after reaching Rails 4.1.6. For new versions of Rails, and for my latest Rails configuration suggestions, please use mattbrictson/rails-template.
Ruby
99
star
9

dotfiles

bash, git, rails, Sublime Text 3, homebrew, more...
Ruby
84
star
10

gem

A GitHub template for creating Ruby gems
Ruby
42
star
11

pgcli-rails

Replaces Rails PostgreSQL `dbconsole` with the much nicer `pgcli`
Ruby
33
star
12

minitest-snapshots

Minitest plugin for asserting that strings are the same as a saved snapshot, jest style
Ruby
33
star
13

mighty_test

A modern, TDD-friendly Minitest runner for Ruby projects! Includes a Jest-inspired interactive watch mode, focus mode, CI sharding, fail-fast, and more.
Ruby
6
star
14

jess

Lightweight, unofficial client for the JAMF Software Server (JSS) API
Ruby
5
star
15

tomo-plugin-sidekiq

sidekiq tasks for tomo
Ruby
4
star
16

tomo-plugin

A GitHub template for creating tomo plugins
Ruby
2
star
17

tomo-plugin-nvm

tomo plugin to manage node and yarn via nvm
Ruby
2
star
18

tomo-plugin-rollbar

rollbar tasks for tomo
Ruby
2
star
19

rails-new

Ruby
1
star