Я создаю приложение, используя Ruby on Rails, следуя руководству Майкла Хартла по Rails. Я попытался развернуть приложение на heroku, и, очевидно, у меня не было проблем с этим, но как только я открываю приложение на heroku, оно показывает мне ошибку приложения. Я почти ничего не понимаю ... это файл журнала:

-----> Ruby app detected
-----> Compiling Ruby/Rails
-----> Using Ruby version: ruby-1.9.3
###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile

-----> Installing dependencies using 1.6.3
       Running: bundle install --without development:test --path vendor/bundle --binstubs vendor/bundle/bin -j4
       Your Gemfile lists the gem rspec-rails (>= 0) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem jquery-rails (= 3.0.4) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem pg (= 0.15.1) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem rails_12factor (= 0.0.2) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Fetching git://github.com/bmabey/database_cleaner.git
       Fetching gem metadata from https://rubygems.org/.........
       Resolving dependencies...
       Using rake 10.3.2
       Using i18n 0.6.11
       Using minitest 4.7.5
       Using thread_safe 0.3.4
       Using multi_json 1.10.1
       Using tzinfo 0.3.41
       Using builder 3.1.4
       Using erubis 2.7.0
       Using mime-types 1.25.1
       Using rack 1.5.2
       Using polyglot 0.3.5
       Using activerecord-deprecated_finders 1.0.3
       Using arel 4.0.2
       Using bcrypt-ruby 3.1.2
       Using sass 3.4.4
       Using will_paginate 3.0.4
       Using bundler 1.6.3
       Using coffee-script-source 1.8.0
       Using execjs 2.2.1
       Using hike 1.2.3
       Using thor 0.19.1
       Using json 1.8.1
       Using pg 0.15.1
       Using tilt 1.4.1
       Using rails_serve_static_assets 0.0.2
       Using rails_stdout_logging 0.0.3
       Using faker 1.1.2
       Using activesupport 4.0.2
       Using treetop 1.4.15
       Using rack-test 0.6.2
       Using bootstrap-will_paginate 0.0.9
       Using bootstrap-sass 2.3.2.0
       Using coffee-script 2.3.0
       Using rdoc 3.12.2
       Using uglifier 2.1.1
       Using rails_12factor 0.0.2
       Using sprockets 2.10.1
       Using actionpack 4.0.2
       Using activemodel 4.0.2
       Using jbuilder 1.0.2
       Using mail 2.5.4
       Using sdoc 0.3.20
       Using railties 4.0.2
       Using sprockets-rails 2.0.1
       Using actionmailer 4.0.2
       Using activerecord 4.0.2
       Using coffee-rails 4.0.1
       Using jquery-rails 3.0.4
       Using sass-rails 4.0.1
       Using rails 4.0.2
       Using turbolinks 1.1.1
       Your bundle is complete!
       Gems in the groups development and test were not installed.
       It was installed into ./vendor/bundle
       Bundle completed (8.32s)
       Cleaning up the bundler cache.
       Your Gemfile lists the gem rspec-rails (>= 0) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem jquery-rails (= 3.0.4) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem pg (= 0.15.1) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
       Your Gemfile lists the gem rails_12factor (= 0.0.2) more than once.
       You should probably keep only one of them.
       While it's not a problem now, it could cause errors if you change the version of just one of them later.
-----> Writing config/database.yml to read from DATABASE_URL
       Detected manifest file, assuming assets were compiled locally

###### WARNING:
       Removing `Gemfile.lock` because it was generated on Windows.
       Bundler will do a full resolve so native gems are handled properly.
       This may result in unexpected gem versions being used in your app.
       In rare occasions Bundler may not be able to resolve your dependencies at all.
       https://devcenter.heroku.com/articles/bundler-windows-gemfile

-----> Discovering process types
       Procfile declares types -> web
       Default types for Ruby  -> console, rake, worker

-----> Compressing... done, 23.0MB
-----> Launching... done, v27
       http://guarded-shelf-9628.herokuapp.com/ deployed to Heroku

Сравнив его с журналами предыдущих успешных развертываний, я обнаружил небольшую разницу. В этом журнале написано Default types for ruby -> console, rake, worker, в то время как в других журналах успешных развертываний указано Default types for ruby -> console, rake, web, worker, так что веб , возможно, там отсутствует и может быть причиной проблем ... Вы думаешь, в этом может быть проблема? Если это проблема ... Я не знаю, как это исправить! :) Хотел бы услышать от кого-нибудь, кто мог бы мне помочь с этим! Заранее большое спасибо!

Вот журнал, который может предоставить информацию об ошибке:

2014-09-19T22:58:43.981295+00:00 app[web.1]:
2014-09-19T22:58:43.981299+00:00 app[web.1]: `config/application.rb` file and an
y `mass_assignment_sanitizer` options
2014-09-19T22:58:43.981302+00:00 app[web.1]:
2014-09-19T22:58:43.981294+00:00 app[web.1]: params or add `protected_attributes
` to your Gemfile to use the old one.
2014-09-19T22:58:43.981300+00:00 app[web.1]: from your `config/environments/*.rb
` files.
2014-09-19T22:58:43.981330+00:00 app[web.1]:
2014-09-19T22:58:44.252040+00:00 app[web.1]: A server is already running. Check
/app/tmp/pids/server.pid.
2014-09-19T22:58:44.252144+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2014-09-19T22:58:44.252142+00:00 app[web.1]: => Rails 4.0.2 application starting
 in production on http://0.0.0.0:23779
2014-09-19T22:58:44.252140+00:00 app[web.1]: => Booting WEBrick
2014-09-19T22:58:44.252145+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-19T22:58:44.252147+00:00 app[web.1]: Exiting
2014-09-19T22:58:45.031535+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-09-19T22:58:45.020850+00:00 heroku[web.1]: Process exited with status 1
2014-09-19T23:00:06.776445+00:00 heroku[api]: Starting process with command `bun
dle exec rake db:migrate` by xxxxxxxx@hotmail.com
2014-09-19T23:00:09.905857+00:00 heroku[run.8558]: Awaiting client
2014-09-19T23:00:09.944483+00:00 heroku[run.8558]: Starting process with command
 `bundle exec rake db:migrate`
2014-09-19T23:00:10.286566+00:00 heroku[run.8558]: State changed from starting t
o up
2014-09-19T23:00:15.233196+00:00 heroku[run.8558]: State changed from up to comp
lete
2014-09-19T23:00:15.217870+00:00 heroku[run.8558]: Process exited with status 0
2014-09-19T23:09:00.021083+00:00 heroku[web.1]: State changed from crashed to st
arting
2014-09-19T23:09:06.045524+00:00 heroku[web.1]: Starting process with command `b
undle exec rails server -p 52238`
2014-09-19T23:09:08.517868+00:00 app[web.1]: Your Gemfile lists the gem rspec-ra
ils (>= 0) more than once.
2014-09-19T23:09:08.525341+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.525343+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.517884+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.517887+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.518722+00:00 app[web.1]: Your Gemfile lists the gem jquery-r
ails (= 3.0.4) more than once.
2014-09-19T23:09:08.535911+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.535913+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.518726+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:08.518728+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:08.525337+00:00 app[web.1]: Your Gemfile lists the gem pg (= 0.
15.1) more than once.
2014-09-19T23:09:08.535904+00:00 app[web.1]: Your Gemfile lists the gem rails_12
factor (= 0.0.2) more than once.
2014-09-19T23:09:16.478210+00:00 app[web.1]: DEPRECATION WARNING: config.whiny_n
ils option is deprecated and no longer works. (called from block in <top (requir
ed)> at /app/config/environments/production.rb:6)
2014-09-19T23:09:16.602557+00:00 app[web.1]:
2014-09-19T23:09:16.602552+00:00 app[web.1]: config.eager_load is set to nil. Pl
ease update your config/environments/*.rb files accordingly:
2014-09-19T23:09:16.602560+00:00 app[web.1]:   * development - set it to false
2014-09-19T23:09:16.602561+00:00 app[web.1]:   * test - set it to false (unless
you use a tool that preloads your test environment)
2014-09-19T23:09:16.602563+00:00 app[web.1]:   * production - set it to true
2014-09-19T23:09:16.602564+00:00 app[web.1]:
2014-09-19T23:09:16.602588+00:00 app[web.1]:
2014-09-19T23:09:18.980362+00:00 app[web.1]: DEPRECATION WARNING: Model based ma
ss assignment security has been extracted
2014-09-19T23:09:18.980372+00:00 app[web.1]:
2014-09-19T23:09:18.980380+00:00 app[web.1]: See http://guides.rubyonrails.org/s
ecurity.html#mass-assignment for more information.
2014-09-19T23:09:18.980375+00:00 app[web.1]: `config/application.rb` file and an
y `mass_assignment_sanitizer` options
2014-09-19T23:09:18.980378+00:00 app[web.1]:
2014-09-19T23:09:18.980374+00:00 app[web.1]: To disable this message remove the
`whitelist_attributes` option from your
2014-09-19T23:09:18.980377+00:00 app[web.1]: from your `config/environments/*.rb
` files.
2014-09-19T23:09:18.980406+00:00 app[web.1]:
2014-09-19T23:09:18.980370+00:00 app[web.1]: params or add `protected_attributes
` to your Gemfile to use the old one.
2014-09-19T23:09:18.980368+00:00 app[web.1]: out of Rails into a gem. Please use
 the new recommended protection model for
2014-09-19T23:09:19.458144+00:00 app[web.1]: => Rails 4.0.2 application starting
 in production on http://0.0.0.0:52238
2014-09-19T23:09:19.458184+00:00 app[web.1]: Exiting
2014-09-19T23:09:19.458145+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2014-09-19T23:09:19.458147+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-19T23:09:19.458138+00:00 app[web.1]: => Booting WEBrick
2014-09-19T23:09:19.450797+00:00 app[web.1]: A server is already running. Check
/app/tmp/pids/server.pid.
2014-09-19T23:09:20.395099+00:00 heroku[web.1]: Process exited with status 1
2014-09-19T23:09:20.407213+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-09-19T23:09:20.407904+00:00 heroku[web.1]: State changed from crashed to st
arting
2014-09-19T23:09:24.294382+00:00 heroku[web.1]: Starting process with command `b
undle exec rails server -p 11906`
2014-09-19T23:09:26.659179+00:00 app[web.1]: Your Gemfile lists the gem rspec-ra
ils (>= 0) more than once.
2014-09-19T23:09:26.659198+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:26.659196+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.659738+00:00 app[web.1]: Your Gemfile lists the gem jquery-r
ails (= 3.0.4) more than once.
2014-09-19T23:09:26.659743+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:26.659741+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.664097+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.664091+00:00 app[web.1]: Your Gemfile lists the gem pg (= 0.
15.1) more than once.
2014-09-19T23:09:26.664325+00:00 app[web.1]: Your Gemfile lists the gem rails_12
factor (= 0.0.2) more than once.
2014-09-19T23:09:26.664099+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:26.664328+00:00 app[web.1]: You should probably keep only one o
f them.
2014-09-19T23:09:26.664330+00:00 app[web.1]: While it's not a problem now, it co
uld cause errors if you change the version of just one of them later.
2014-09-19T23:09:28.647892+00:00 app[web.1]: DEPRECATION WARNING: config.whiny_n
ils option is deprecated and no longer works. (called from block in <top (requir
ed)> at /app/config/environments/production.rb:6)
2014-09-19T23:09:28.717340+00:00 app[web.1]: config.eager_load is set to nil. Pl
ease update your config/environments/*.rb files accordingly:
2014-09-19T23:09:28.717344+00:00 app[web.1]:
2014-09-19T23:09:28.717346+00:00 app[web.1]:   * development - set it to false
2014-09-19T23:09:28.717347+00:00 app[web.1]:   * test - set it to false (unless
you use a tool that preloads your test environment)
2014-09-19T23:09:28.717349+00:00 app[web.1]:   * production - set it to true
2014-09-19T23:09:28.717350+00:00 app[web.1]:
2014-09-19T23:09:28.717352+00:00 app[web.1]:
2014-09-19T23:09:29.932824+00:00 app[web.1]: DEPRECATION WARNING: Model based ma
ss assignment security has been extracted
2014-09-19T23:09:29.932830+00:00 app[web.1]: out of Rails into a gem. Please use
 the new recommended protection model for
2014-09-19T23:09:29.932831+00:00 app[web.1]: params or add `protected_attributes
` to your Gemfile to use the old one.
2014-09-19T23:09:29.932833+00:00 app[web.1]:
2014-09-19T23:09:30.174451+00:00 app[web.1]: => Run `rails server -h` for more s
tartup options
2014-09-19T23:09:29.932835+00:00 app[web.1]: To disable this message remove the
`whitelist_attributes` option from your
2014-09-19T23:09:29.932838+00:00 app[web.1]: from your `config/environments/*.rb
` files.
2014-09-19T23:09:29.932836+00:00 app[web.1]: `config/application.rb` file and an
y `mass_assignment_sanitizer` options
2014-09-19T23:09:29.932842+00:00 app[web.1]:
2014-09-19T23:09:29.932839+00:00 app[web.1]:
2014-09-19T23:09:30.174417+00:00 app[web.1]: A server is already running. Check
/app/tmp/pids/server.pid.
2014-09-19T23:09:30.174453+00:00 app[web.1]: => Ctrl-C to shutdown server
2014-09-19T23:09:29.932841+00:00 app[web.1]: See http://guides.rubyonrails.org/s
ecurity.html#mass-assignment for more information.
2014-09-19T23:09:30.174447+00:00 app[web.1]: => Booting WEBrick
2014-09-19T23:09:30.174454+00:00 app[web.1]: Exiting
2014-09-19T23:09:30.174450+00:00 app[web.1]: => Rails 4.0.2 application starting
 in production on http://0.0.0.0:11906
2014-09-19T23:09:31.093052+00:00 heroku[web.1]: State changed from starting to c
rashed
2014-09-19T23:09:31.072183+00:00 heroku[web.1]: Process exited with status 1
2014-09-19T23:09:33.082176+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path="/" host=guarded-shelf-9628.herokuapp.com request_id=fae64
19e-d8ca-498f-ab94-936295266fe4 fwd="190.195.118.32" dyno= connect= service= sta
tus=503 bytes=
0
santib 20 Сен 2014 в 02:48
Вы запускали миграции? heroku run rake db:migrate
 – 
BroiSatse
20 Сен 2014 в 02:55
Да, я сделал, но все еще та же проблема :/
 – 
santib
20 Сен 2014 в 03:01
Запустите heroku logs и покажите вывод. (Кроме того, запускали ли вы перезапуск heroku после миграции? Модели кэшируются в процессе производства)
 – 
BroiSatse
20 Сен 2014 в 03:01
2014-09-19T23:09:31.072183+00:00 heroku[web.1]: Процесс завершен со статусом 1 2014-09-19T23:09:33.082176+00:00 heroku[router]: at=код ошибки=H10 desc Метод ="Сбой приложения" = GET path="/" host=guarded-shelf-9628.herokuapp.com request_id=fae64 19e-d8ca-498f-ab94-936295266fe4 fwd="190.195.118.32" dyno=connect=service= статус=503 байт=
 – 
santib
20 Сен 2014 в 03:11
1
Попробуйте запустить приложение локально в производственном режиме rake assets:precompile; rails s -e production
 – 
PGill
20 Сен 2014 в 10:28

2 ответа

Лучший ответ

Для всех, кому интересно ... после нескольких часов попыток ВСЕГО я, наконец, смог решить эту проблему!

Дело в том, что в моем файле server.pid что-то не так ... вместо числа в моей основной ветке была только строка текста с надписью "регистрация", что выглядело довольно странно, поэтому я перешел в предыдущую ветку, над которой работал, скопировал содержимое файла server.pid и вставил его в тот, который находится в главной ветке, зафиксировал и отправил на heroku, и теперь приложение работает плавно! :)

Большое спасибо всем, кто внес свой вклад!

1
santib 21 Сен 2014 в 02:13
Где вы найдете этот файл server.pid?
 – 
B Woods
1 Апр 2015 в 16:12

Ошибки

В Heroku есть два типа ошибок - ошибка платформы и ошибка синтаксиса (Rails) :

-

< Сильный > Платформа

enter image description here

Первая проблема - ошибка платформы .

Это уровень Heroku, и в основном это означает, что ваша «система» (платформа) работает некорректно. Либо у вас отсутствует / сломана зависимость, либо конфигурация платформы неверна.

В большинстве случаев причина, по которой это отображается, заключается в том, что вы не указали правильную базу данных, что не позволяет вашему приложению даже запуститься. Я объясню, как это исправить ниже

-

Синтаксис

enter image description here

Это проблема Rails , означающая, что вся ваша технология уровня "платформы" будет работать правильно. Если вы получаете одну из этих ошибок, это в основном означает, что у вас есть какая-то проблема с самим приложением Rails (а не только с платформой, на которой оно работает).

Получение этого типа ошибки в основном означает, что вам нужно исправить проблему с вашим кодом (а не с платформой). Хотя это может означать зависимости


Исправить

Из вашей ошибки очевидно, что у вас проблема с Heroku, а не с рельсами. С этой целью я бы рекомендовал следующее:

  1. Проверьте конфигурацию базы данных для своего приложения.
  2. Проверьте, правильно ли он перенесен.
  3. Проверьте, все ли обновлено и зависимости работают.

Во-первых, и это наиболее важно, вам необходимо убедиться, что у вас есть «производственная» база данных, назначенная в Heroku * . Хотя вы можете использовать любую базу данных, лучше всего использовать встроенную в Heroku настройку PGSQL - который, если он установлен с панели инструментов Heroku, должен дать вашему приложению возможность запускать производственную базу данных

Во-вторых, вам необходимо перейти на эту базу данных. Вы можете сделать это, запустив heroku run rake db:migrate в вашей локальной системе разработки, которая заполнит базу данных, описанную выше.

Наконец, вы захотите убедиться, что Heroku имеет все соответствующие зависимости и т. Д. Это делается с помощью надстроек, и, честно говоря, вряд ли будет присутствовать в вашей проблеме (это действительно редко).

0
Richard Peck 20 Сен 2014 в 03:52
Спасибо за ваш ответ! Моя конфигурация базы данных для моего приложения, по-видимому, в порядке. Я использую PGSQL, и в моих файлах database.yml postgresql установлен как адаптер во всех трех средах. Я перешел на свою базу данных postgresql на своем локальном компьютере и проверил схемы в средах разработки и производства, и они там есть. На всякий случай я выполнил предварительную компиляцию перед переходом на heroku, и после того, как я отправил код в Heroku, я запустил «heroku run rake db: migrate»… Как мне убедиться, что у меня есть «производственная» база данных, назначенная в heroku? У меня также есть добавление heroku postgres::crimson
 – 
santib
20 Сен 2014 в 04:37