3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

heroku関連コマンド一覧

3
Last updated at Posted at 2020-02-28

herokuでアプリをデプロイする頻度が高く、コマンドを見返せるようにメモ。

アプリ作成コマンド

$ heroku create

heroku create 任意のアプリ名でアプリ名の指定可能。
(指定しなかった場合は、heroku側で自動付与)

環境変数の確認コマンド

//環境変数の一覧表示
$ heroku config

//指定した値のみを表示
$ heroku config:get 任意のENV_NAME

環境変数の設定コマンド

//環境変数の設定
$ heroku config:set 任意のENV_NAME=//例
$ heroku config:set SECRET_KEY='************************'

//環境変数の削除
$ heroku config:unset 任意のENV_NAME

デプロイコマンド

$ git push heroku master

Gitを使ってheroku上のmasterブランチにアプリをデプロイ。

アプリ(デプロイ済)オープンコマンド

$ heroku open

アプリを開く。

アプリ更新コマンド

$ git push heroku master

herokuリポジトリへ再度pushすることで更新。

アプリ削除コマンド

$ heroku apps:destroy --app 任意のアプリ名
$ heroku apps:destroy --app 任意のアプリ名 --confirm 任意のアプリ名

Heroku上のアプリもリモートリポジトリの設定もすべて削除。
--confirm 任意のアプリ名を付けて実行した場合、確認のアプリ名の入力は省略。

データベース(PostgreSQL)接続コマンド

$ heroku pg:psql

任意のアプリ名::DATABASE=> (SQL文の実行)

//終了コマンド
任意のアプリ名::DATABASE=> \q

データベースリセットコマンド

$ heroku pg:reset DATABASE

//マイグレートの実行忘れずに(下記Djangoの場合)
$ heroku run python manage.py migrate

$ heroku run python manage.py createsuperuser

*マイグレートの実行忘れると、エラーが出てしまう。

データベース行数確認コマンド

$ heroku pg:info

=== DATABASE_URL
Plan:                  *******
Status:                *******
Connections:           *******
PG Version:            *******
Created:               *******
Data Size:             *******
Tables:                *******
Rows:                  4119/10000 (In compliance)
Fork/Follow:           *******
Rollback:              *******
Continuous Protection: *******
Add-on:                *******

herokuのPostgresqlは無料プランの場合、10000行までと制限あり。
上記のRows:項目で確認可能。

Dyno使用量確認コマンド

$ heroku ps

Free dyno hours quota remaining this month: 517h 25m (94%)
Free dyno usage for this app: 30h 43m (5%)

1アカウントごとに、550時間/月の無料Dynoが付与(クレジットカード登録を行うと450時間/月の無料Dynoが加算)と無料枠の制限があるため上記のように確認可能。

3
2
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
3
2

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?