2012-12-06 33 views
2

我試圖部署一個新的安裝Publify博客Heroku。一切工作正常我的本地計算機上。部署Publify博客Heroku導致應用程序錯誤

而且git push heroku master不說有關問題的任何東西:

Counting objects: 7, done. 
Delta compression using up to 2 threads. 
Compressing objects: 100% (4/4), done. 
Writing objects: 100% (6/6), 786 bytes, done. 
Total 6 (delta 1), reused 0 (delta 0) 

-----> Heroku receiving push 
-----> Ruby/Rails app detected 
-----> Installing dependencies using Bundler version 1.2.2 
     Running: bundle install --without development:test --path 
     vendor/bundle --binstubs bin/ --deployment 

     Using rake (10.0.2) 

     ... (edited out list of gems being used) 

     Your bundle is complete! It was installed into ./vendor/bundle 
     Cleaning up the bundler cache. 
-----> Writing config/database.yml to read from DATABASE_URL 
-----> Rails plugin injection 
     Injecting rails_log_stdout 
     Injecting rails3_serve_static_assets 
-----> Discovering process types 
     Procfile declares types  -> (none) 
     Default types for Ruby/Rails -> console, rake, web, worker 
-----> Compiled slug size: 10.7MB 
-----> Launching... done, v7 
     http://desolate-harbor-2909.herokuapp.com deployed to Heroku 

To [email protected]:desolate-harbor-2909.git 
    cea2c5c..efb4eb2 master -> master 

但在那之後我看到這個應用頁面:

應用程序錯誤
應用程序中發生錯誤,您的頁面可能不被服務。請稍後重試。

如果您是應用程序所有者,請查看您的日誌以瞭解詳細信息。

和Heroku的日誌顯示此:

heroku[slugc]: Slug compilation started 
heroku[api]: Release v7 created by [email protected] 
heroku[api]: Deploy efb4eb2 by [email protected] 
heroku[web.1]: State changed from crashed to starting 
heroku[slugc]: Slug compilation finished 
heroku[web.1]: Starting process with command `bundle exec rails server -p 50812` 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/dsl.rb:7:in `evaluate' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/bin/bundle:14:in `<top (required)>' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/dsl.rb:32:in `instance_eval' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors' 
app[web.1]: There was an error in your Gemfile, and Bundler cannot continue. 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/cli.rb:423:in `exec' 
app[web.1]:  /app/Gemfile:7:in `eval_gemfile' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/dsl.rb:32:in `eval_gemfile' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/definition.rb:18:in `build' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler.rb:144:in `definition' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor/task.rb:27:in `run' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor.rb:275:in `dispatch' 
app[web.1]:  /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/bin/bundle:23:in `load' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor/base.rb:408:in `start' 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/bin/bundle:14:in `block in <top (required)>' 
app[web.1]: /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load': syntax error on line 27, col 0: `adapter = uri.scheme' (ArgumentError) 
app[web.1]:  /app/vendor/bundle/ruby/1.9.1/bin/bundle:23:in `<main>' 
heroku[web.1]: Process exited with status 4 
heroku[web.1]: State changed from starting to crashed 
heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=desolate-harbor-2909.herokuapp.com fwd=171.5.16.142 dyno= queue= wait= connect= service= status=503 bytes= 
heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=desolate-harbor-[2909.herokuapp.com][1] fwd=171.5.16.142 dyno= queue= wait= connect= service= status=503 bytes= 

我做錯了什麼?我想我需要在部署到Heroku之前設置它。

database.yml文件是:

login: &login 
    adapter: postgresql 
    host: localhost 
    username: ***** 
    password: ***** 

development: 
    database: typo_dev 
    <<: *login 

test: 
    database: typo_tests 
    <<: *login 

production: 
    database: typo 
    <<: *login 

Heroku的運行耙分貝:遷移輸出是:

Running `rake db:migrate` attached to terminal... up, run.7604 
/usr/local/lib/ruby/1.9.1/syck.rb:135:in `load': syntax error on line 27, col 0: `adapter = uri.scheme' (ArgumentError) 
     /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load' 
     /app/Gemfile:7:in `eval_gemfile' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/dsl.rb:32:in `instance_eval' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/dsl.rb:32:in `eval_gemfile' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/dsl.rb:7:in `evaluate' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/definition.rb:18:in `build' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler.rb:144:in `definition' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/cli.rb:423:in `exec' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor/task.rb:27:in `run' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor/invocation.rb:120:in `invoke_task' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor.rb:275:in `dispatch' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/vendor/thor/base.rb:408:in `start' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/bin/bundle:14:in `block in <top (required)>' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/lib/bundler/friendly_errors.rb:4:in `with_friendly_errors' 
     /app/vendor/bundle/ruby/1.9.1/gems/bundler-1.2.2/bin/bundle:14:in `<top (required)>' 
     /app/vendor/bundle/ruby/1.9.1/bin/bundle:23:in `load' 
     /app/vendor/bundle/ruby/1.9.1/bin/bundle:23:in `<main>' 
There was an error in your Gemfile, and Bundler cannot continue. 
+0

你配置了你的數據庫嗎?如果是這樣,你可以發佈你的配置嗎?您運行的是 –

+0

:heroku rake db:migrate? –

+0

請注意,在Heroku中,您的'database.url'被替換 - '寫入config/database.yml以從DATABASE_URL中讀取。請參閱[Ruby buildpack](https://github.com/heroku/heroku-buildpack-ruby/blob/v42/lib/language_pack/ruby.rb#L441-504)。 – matt

回答

2

當Rails的加載database.yml文件,它實際上filters it through ERB before loading it as a Yaml file。這樣可以使用Ruby動態創建配置,例如將密碼保存在存儲庫中。

當您將Rails應用程序推送到Heroku時,a new database.yml file is created, replacing the original。這個新的database.yml使用ERB從DATABASE_URL環境變量構建配置,所以實際上它不是一個「純粹的」Yaml文件 - 你可以認爲它是類似database.yml.erb的東西。

錯字的Gemfile loads the database.yml file然後parses it as Yaml,但不是通過ERB先餵它。您看到的錯誤是由Yaml解析器讀取文件引起的,但由於它是ERB而無法正常工作,所以Yaml無效。

要修復它,您需要確保database.yml文件在被讀爲Yaml之前通過ERB。在您的Gemfile更改的行

conf = YAML.load(File.read(dbfile)) 

require 'erb' 
conf = YAML.load(ERB.new(File.read(dbfile)).result) 

你可能想打開的bug報告錯字,甚至發送pull請求。

+0

有一個錯字:不是Rakefile,而是Gemfile。除此之外,這爲我工作。謝謝。 –

+0

@JanWrobel謝謝!固定。 – matt

相關問題