Skip to content

Instantly share code, notes, and snippets.

@andrewkatz
Created May 6, 2013 17:22
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewkatz/5526552 to your computer and use it in GitHub Desktop.
Save andrewkatz/5526552 to your computer and use it in GitHub Desktop.
Simple command for ssh'ing into rails hosts. Thanks to @trobrock for the ruby script.
# Usage:
# rails_ssh release cron
# => ssh release@ec2-xx-xx-xx-xx.compute-1.amazonaws.com
rails_ssh()
{
username=$1
hostname="$(ruby $HOME/Scripts/parse_cap_config.rb $2)"
ssh $username@$hostname
}
# Example Usage:
# rssh cron
# rssh web1
alias rssh='rails_ssh release'
#!/usr/bin/env ruby
wanting = ARGV[0]
role = wanting.scan(/[a-z]+/).first.to_sym
number = wanting.scan(/\d+/).first.to_i
ROLES = {}
def role(role, *hosts)
hosts.pop if hosts.last.is_a?(Hash)
ROLES[role] = hosts
end
def method_missing(meth, *args, &block)
end
load "config/deploy/production.rb"
puts ROLES[role][number-1]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment