当我在我的Procfile中包含web: rails:db:migrate
时,它会导致我的rails应用程序崩溃。当我通过浏览器使用Heroku控制台运行rails db:migrate
时,它运行正常。
2018-01-20T08:01:30.465226+00:00 heroku[web.1]: Starting process with command `rails db:migrate`
2018-01-20T08:01:34.612837+00:00 app[web.1]: I, [2018-01-20T08:01:34.206214 #4] INFO -- : [SKYLIGHT] [1.5.0] Skylight agent enabled
2018-01-20T08:01:34.612854+00:00 app[web.1]: D, [2018-01-20T08:01:34.576132 #4] DEBUG -- : [1m[35m (1.0ms)[0m [1m[34mSELECT pg_try_advisory_lock(8624398319468495445)[0m
2018-01-20T08:01:34.612855+00:00 app[web.1]: D, [2018-01-20T08:01:34.589800 #4] DEBUG -- : [1m[35m (1.5ms)[0m [1m[34mSELECT "schema_migrations"."version" FROM "schema_migrations" ORDER BY "schema_migrations"."version" ASC[0m
2018-01-20T08:01:34.612857+00:00 app[web.1]: D, [2018-01-20T08:01:34.597079 #4] DEBUG -- : [1m[36mActiveRecord::InternalMetadata Load (1.2ms)[0m [1m[34mSELECT "ar_internal_metadata".* FROM "ar_internal_metadata" WHERE "ar_internal_metadata"."key" = $1 LIMIT $2[0m [["key", "environment"], ["LIMIT", 1]]
2018-01-20T08:01:34.612858+00:00 app[web.1]: D, [2018-01-20T08:01:34.604685 #4] DEBUG -- : [1m[35m (1.0ms)[0m [1m[35mBEGIN[0m
2018-01-20T08:01:34.612859+00:00 app[web.1]: D, [2018-01-20T08:01:34.606578 #4] DEBUG -- : [1m[35m (1.0ms)[0m [1m[35mCOMMIT[0m
2018-01-20T08:01:34.612860+00:00 app[web.1]: D, [2018-01-20T08:01:34.607768 #4] DEBUG -- : [1m[35m (1.0ms)[0m [1m[34mSELECT pg_advisory_unlock(8624398319468495445)[0m
2018-01-20T08:01:34.692625+00:00 heroku[web.1]: State changed from starting to crashed
2018-01-20T08:01:34.670371+00:00 heroku[web.1]: Process exited with status 0
答案 0 :(得分:2)
在Procfile
中,web
适用于网络服务器,例如:
web: bundle exec puma -C config/puma.rb
为了在部署到Heroku时运行迁移,您需要将此行附加到Procfile
:
release: rake db:migrate