Last Updated: February 25, 2016
·
1.307K
· rahult

Karo - A command line companion for a Rails application

Karo is a command line companion for a rails application which makes performing routine commands locally or on the server easier.

Github - https://github.com/rahult/karo

Website - http://rahult.github.io/karo/

Example of things it can do, for rest please refer to karo help

karo db pull # Will sync the production MySQL database on to local machine
karo db console # Will open MySQL console on the server
karo console # Will open Rails console on the server
karo assets pull -e staging # Will sync the dragonfly assets from staging on to the local machine
karo log -f # Will tail the production log with -f argument

You can also write your custom commands

karo server {command} # Will try to find a command from .karo.yml or execute the one provided on the server
karo client {command} # Will try to find a command from .karo.yml or execute the one provided on the client

Few Assumptions

  • You have SSH access to your servers
  • You have the Capistrano deploy directory structure on your server
    [deployto]
    [deploy
    to]/releases
    [deployto]/releases/20080819001122
    [deploy
    to]/releases/...
    [deployto]/shared
    [deploy
    to]/shared/config/database.yml
    [deployto]/shared/log
    [deploy
    to]/shared/pids
    [deployto]/shared/system
    [deploy
    to]/current -> [deploy_to]/releases/20100819001122
  • You are using MySQL as your database server
  • You are using Dragonfly to store your assets

I am working on supporting other databases and assets managers for future releases

Installation

Karo is released as a Ruby Gem. The gem is to be installed within a Ruby
on Rails application. To install, simply add the following to your Gemfile:

# Gemfile
gem 'karo'

After updating your bundle, you can use Karo function from the command line

Usage (command line)

karo help

Default configuration file (.karo.yml)

production:
  host: example.com
  user: deploy
  path: /data/app_name
  commands:
    server:
      memory: watch vmstat -sSM
      top_5_memory: ps aux | sort -nk +4 | tail
    client:
      deploy: cap production deploy
staging:
  host: example.com
  user: deploy
  path: /data/app_name
  commands:
    server:
      memory: vmstat -sSM
    client:
      deploy: ey deploy -e staging -r staging