Heroku Cheat Sheet

From WikiOD

Here is the cheatsheat of Heroku and basic guide on how to use Heroku

create - Create an app[edit | edit source]

heroku create sushi
git push heroku master

access - Collaboration[edit | edit source]

Manage collaborators[edit | edit source]

heroku access                     # List
heroku access:add me@xy.com
heroku access:remove me@xy.com

Transfer to another owner[edit | edit source]

heroku apps:transfer new@owner.com

logs - Show logs[edit | edit source]

heroku logs
heroku logs -t      # --tail (stream)
heroku logs -s app  # --source (only on app logs)

releases[edit | edit source]

heroku releases
heroku releases:info v25
heroku rollback

pg - PostgreSQL[edit | edit source]

Start a database[edit | edit source]

heroku addons:add heroku-postgresql

Enable backups[edit | edit source]

heroku addons:add pgbackups:auto-month

See: Heroku PostgreSQL (devcenter.heroku.com)

config - Environment var configuration[edit | edit source]

Listing[edit | edit source]

heroku config        # List
heroku config -s     # List in shell format

Getting[edit | edit source]

heroku config:get KEY

Setting[edit | edit source]

heroku config:set KEY=val
heroku config:set KEY1=val KEY2=val ...
heroku config:unset KEY1

apps - Applications[edit | edit source]

heroku apps                  # list
heroku apps:create [NAME]
heroku apps:destroy --app APP
heroku apps:info
heroku apps:open             # open in browser
heroku apps:rename NEWNAME

maintenance[edit | edit source]

heroku maintenance:on
heroku maintenance:off

Processes[edit | edit source]

ps - Managing processes[edit | edit source]

heroku ps              # list
heroku ps:scale web=1  # spawn more dynos

restart[edit | edit source]

heroku restart

run - Running tasks[edit | edit source]

heroku run bash
heroku run console                  # Rails console
heroku run rake assets:precompile

Domains[edit | edit source]

domains - Custom domains[edit | edit source]

Add both![edit | edit source]

heroku domains:add example.com
heroku domains:add www.example.com

Removing[edit | edit source]

heroku domains:clear
heroku domains:remove example.com

See: Custom domains (devcenter.heroku.com)

Wildcard domains[edit | edit source]

heroku addons:add wildcard_domains
*.yourdomain.com => heroku.com

Other tricks[edit | edit source]

htpasswd (for PHP apps)[edit | edit source]

Create an .htaccess file in the webroot:

AuthUserFile /app/www/.htpasswd
AuthType Basic
AuthName "Restricted Access"
Require valid-user

Create a .htpasswd file:

$ htpasswd -c .htpasswd [username]

See: gist.github.com

References[edit | edit source]