All notes
Heroku

Quick start

Installation

heroku.com: heroku-cli.


brew install heroku

heroku --version

heroku login

# To login with another username:
mv ~/.netrc ~/.netrc.backup
heroku login

Auto update

If a new version is found, it will be downloaded and stored in ~/.local/share/heroku/cli. This background check will happen at most once every 4 hours.

Uninstall


rm -rf /usr/local/heroku
rm -rf ~/.local/share/heroku ~/.config/heroku ~/.cache/heroku

Setup app

heroku.com: get started with nodejs.


cd ~/myapp
heroku create
# When you create an app, a git remote (called heroku) is also created and associated with your local git repository.

heroku config:set TIMES=2 TWITTER_KEY="aaa" TWITTER_SECRET="bbb"
heroku config

git push heroku master

# Ensure that at least one instance of the app is running:
heroku ps:scale web=1
# Check information on the current dyno container:
heroku ps

# Visit the URL by:
heroku open

# See the logs
heroku logs --tail

# Run Procfile web job locally:
heroku local web

Set PORT

Heroku treats web apps just like any other app and doesn't allow you to assign listening ports directly. The port to bind to is assigned by Heroku as the PORT environment variable.

To use it (Heroku will set process.env.PORT for you):


port = process.env.PORT || 80

Procfile

devCenter: procfile.

The web process type is special as it’s the only process type that will receive HTTP traffic from Heroku’s routers. Other process types can be named arbitrarily.