陈斌彬的技术博客

Stay foolish,stay hungry

Heroku - Creating APPs From the CLI

The app is the fundamental unit of organization on Heroku. Each app can be associated with its own set of provisioned add-ons.

Creating a named app

After creating an app, you will probably want to git push to deploy and add collaborators so that others can deploy changes as well.

To create a new app named “example”, install the Heroku Toolbelt and run the following command:

$ heroku create example
Creating example... done, stack is cedar-14
http://example.herokuapp.com/ | git@heroku.com:example.git

The command’s output shows that the app will be available at http://example.herokuapp.com. The second URL, git@heroku.com:example.git, is the remote git repository URL; by default, the heroku create command automatically adds a git remote named “heroku” pointing at this URL.

heroku create is a shorthand alias for heroku apps:create. You can see a list of all commands with heroku help.

Typically, this command will only be used on an initialized git repository. In that case, the command creates the application as well as a git remote, that you can use to push your code to Heroku:

$ mkdir example
$ cd example
$ git init
$ heroku apps:create example
Creating example... done, stack is cedar-14
http://example.herokuapp.com/ | git@heroku.com:example.git
Git remote heroku added

Creating an app without a name

The app name argument (“example”) is optional. If no app name is specified, a random name will be generated.

$ heroku create
Created http://mystic-wind-83.herokuapp.com/ | git@heroku.com:mystic-wind-83.git

Since Heroku app names are in a global namespace, you can expect that common names, like “blog” or “wiki”, will already be taken. It’s often easier to start with a default name and rename the app later.

Welcome page

Once your new app is created, before any code has been deployed, Heroku will display a generic welcome message to its visitors. This page is served with HTTP status code 502 to indicate that the app is not yet running.