基本的にはHeroku Toolbeltを利用してオペレーションをする事になり、簡単な運用方法はHeokuのサイトにまとまっています。
Getting Started with Rails 4.x on Heroku
けっこーな数のコマンドがあります。
$ heroku help
Usage: heroku COMMAND [--app APP] [command-specific-options]
Primary help topics, type "heroku help TOPIC" for more details:
addons # manage addon resources
apps # manage apps (create, destroy)
auth # authentication (login, logout)
config # manage app config vars
domains # manage custom domains
logs # display logs for an app
ps # manage dynos (dynos, workers)
releases # manage app releases
run # run one-off commands (console, rake)
sharing # manage collaborators on an app
Additional topics:
account # manage heroku account options
certs # manage ssl endpoints for an app
drains # display syslog drains for an app
fork # clone an existing app
git # manage git for apps
help # list commands and display help
keys # manage authentication keys
labs # manage optional features
maintenance # manage maintenance mode for an app
pg # manage heroku-postgresql databases
pgbackups # manage backups of heroku postgresql databases
plugins # manage plugins to the heroku gem
regions # list available regions
stack # manage the stack for an app
status # check status of heroku platform
update # update the heroku client
version # display version
Dynoのステータスの確認
heroku ps
=== web (1X): `bin/rails server -p $PORT -e $RAILS_ENV`
web.1: up 2013/10/17 17:38:06 (~ 1h ago)
Rails Consoleもリモートの環境のものがこんな感じで使えてしまいます。
$ heroku run rails console
Running `rails console` attached to terminal... up, run.2213
Loading production environment (Rails 4.0.0)
irb(main):001:0> User.all
=> #<ActiveRecord::Relation [#<User id: 2, email: ...
rakeのCommandもheroku runとタイプするだけで走ってしまう。例えばdb:migrateだったらこんな感じ。
$ heroku run rake db:migrate
Running `rake db:migrate` attached to terminal... up, run.6382
Migrating to DeviseCreateUsers (20131014182214)
== DeviseCreateUsers: migrating ==============================================
-- create_table(:users)
-> 0.0243s
-- add_index(:users, :email, {:unique=>true})
-> 0.0076s
-- add_index(:users, :reset_password_token, {:unique=>true})
-> 0.0087s
== DeviseCreateUsers: migrated (0.0419s) =====================================
$ heroku run rake db:seed
Running `rake db:seed` attached to terminal... up, run.6750
ただ、rake db:migrate:resetとかのDBを書き換えちゃうようなコマンドはPermissionで怒られます。
$ heroku run rake db:migrate:reset
Running `rake db:migrate:reset` attached to terminal... up, run.2597
FATAL: permission denied for database "postgres"
DETAIL: User does not have CONNECT privilege.
そんな時はheroku pgコマンドで対応できるっぽい。
$ heroku pg:reset DATABASE
! WARNING: Destructive Action
! This command will affect the app: $host
! To proceed, type "$host" or re-run this command with --confirm $host
> $host
Resetting HEROKU_POSTGRESQL_AMBER_URL (DATABASE_URL)... done
うーん。超簡単ですね。今後はDatabase周りの細かいオペレーションが必要になってくると思うので、この辺をみながらいじってみて勉強しとこっと。
0 件のコメント:
コメントを投稿