Copied from https://github.com/Homebrew/homebrew/blob/master/Library/Contributions/cmd/brew-services.rb