Created
August 2, 2015 10:58
-
-
Save ssaunier/59832bc7d776a7d9f8de to your computer and use it in GitHub Desktop.
Connect to Heroku RedisCloud as `redis-cli`
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
url_matcher = %r{REDISCLOUD_URL:\s*redis://rediscloud:(\w+)@([\w\-.]+):(\d+)} | |
env_string = `heroku config | grep REDISCLOUD_URL` | |
env_settings = env_string.split('\n') | |
match_data = url_matcher.match(env_settings[0]) | |
db = ARGV[0] || 0 | |
command = %{redis-cli -h #{match_data[2]} -p #{match_data[3]} -a #{match_data[1]} -n #{db}} | |
system command |
Thanks! Also, heroku config:get REDISCLOUD_URL
returns just the URL. So I compacted a bit:
url_matcher = %r{redis://rediscloud:(\w+)@([\w\-.]+):(\d+)}
match_data = url_matcher.match(`heroku config:get REDISCLOUD_URL`)
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Put that in your
~/.bin
folder and add it to your path. Then in any git repo with aheroku
remote, you can just run: