2012-12-31 79 views
0

我在本地機器上安裝了一個工作,但在heroku上無法做到這一點。在Heroku上設置Firefly(ruby link shortener)2.0?

我所做的唯一變化:firefly.yml

  • 改變主機名rxlcc.herokuapp.com
  • 註釋掉的Gemfile其他DBS,只有控球后衛註釋掉

我回購在:https://github.com/hayksaakian/rxlcc

github上的changelog:https://github.com/hayksaakian/rxlcc/commit/d2e2f926b228372a9ff7861e918bdf193a3c3bca

我猜這是因爲有生產數據庫沒有任何連接,但我不能確定這裏我想補充他們

2012-12-31T05:36:20+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 36424` 
2012-12-31T05:36:26+00:00 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) 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/config.ru:2:in `block in <main>' 
2012-12-31T05:36:26+00:00 app[web.1]: from /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/lib/firefly/database.rb:8:in `config' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/lib/firefly/database.rb:13:in `<top (required)>' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/lib/firefly/database.rb:4:in `connect!' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:137:in `start' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/config.ru:1:in `new' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/lib/firefly.rb:30:in `<top (required)>' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/config.ru:1:in `<main>' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/config.ru:2:in `require' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load' 
2012-12-31T05:36:26+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file' 
2012-12-31T05:36:28+00:00 heroku[web.1]: Process exited with status 1 
2012-12-31T05:36:28+00:00 heroku[web.1]: State changed from starting to crashed 
2012-12-31T05:41:04+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=rxlcc.herokuapp.com fwd=71.212.33.130 dyno= queue= wait= connect= service= status=503 bytes= 
2012-12-31T05:41:05+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=rxlcc.herokuapp.com fwd=71.212.33.130 dyno= queue= wait= connect= service= status=503 bytes= 

我的Heroku插件:

heroku-postgresql:dev HEROKU_POSTGRESQL_NAVY 

更新:

我嘗試添加在LIB線/螢火蟲/ server.rb

# suggested by iain on stackoverflow 
    @config[:database_url] = ENV["DATABASE_URL"] 

這似乎並沒有改變任何東西

https://github.com/hayksaakian/rxlcc/commit/638bb8b215cf09f7edbafc0f21e964dfc05f86f2

2013-01-02T06:32:19+00:00 heroku[web.1]: State changed from crashed to starting 
    2013-01-02T06:32:22+00:00 heroku[web.1]: Starting process with command `bundle exec rackup config.ru -p 18667` 
    2013-01-02T06:32:25+00:00 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) 
    2013-01-02T06:32:25+00:00 app[web.1]: from /usr/local/lib/ruby/1.9.1/syck.rb:135:in `load' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/lib/firefly/database.rb:8:in `config' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/lib/firefly/database.rb:4:in `connect!' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/lib/firefly/database.rb:13:in `<top (required)>' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `block in require' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:236:in `load_dependency' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/activesupport-3.2.9/lib/active_support/dependencies.rb:251:in `require' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/lib/firefly.rb:30:in `<top (required)>' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/config.ru:2:in `require' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/config.ru:2:in `block in <main>' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `instance_eval' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:51:in `initialize' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/config.ru:1:in `new' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/config.ru:1:in `<main>' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `eval' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/builder.rb:40:in `parse_file' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:200:in `app' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:301:in `wrapped_app' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:252:in `start' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/lib/rack/server.rb:137:in `start' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.4.1/bin/rackup:4:in `<top (required)>' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load' 
    2013-01-02T06:32:25+00:00 app[web.1]: from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>' 
    2013-01-02T06:32:26+00:00 heroku[web.1]: Process exited with status 1 
    2013-01-02T06:32:27+00:00 heroku[web.1]: State changed from starting to crashed 
    2013-01-02T06:37:44+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=rxlcc.herokuapp.com fwd=71.212.33.130 dyno= queue= wait= connect= service= status=503 bytes= 
    2013-01-02T06:37:44+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/favicon.ico host=rxlcc.herokuapp.com fwd=71.212.33.130 dyno= queue= wait= connect= service= status=503 bytes= 

回答

1

是的,你需要指定數據庫的URL中host:下的YML文件。您可以在Heroku站點的設置頁面中查看網址,也可以運行heroku config --app rxlcc並查找DATABASE_URL。

注意:說明會告訴您如果打算使用Heroku,請更改.gitignore並檢查.yml文件。如果你要保密密鑰在那裏,那麼我不會這樣做,但如果你這樣做,不要使回購公開一個!如果其他人知道一個祕密,您需要需要重新生成它。

個人而言,我將通過

heroku config:add SECRET_VARIABLE=blahblahblah --app rxlcc 

添加任何祕密,然後將其讀入其中,它通過

my_secret_variable = ENV["SECRET_VARIABLE"] 

我看到了應用程序設置配置爲https://github.com/hayksaakian/rxlcc/blob/master/lib/firefly/server.rb#L209,並在之前的塊所需要的應用程序在https://github.com/hayksaakian/rxlcc/blob/master/lib/firefly/server.rb#L109。在任一點你可以嘗試:

@config[:database_url] = ENV["DATABASE_URL"] 

添加任何祕密變量。

+0

我也認爲firefly.yml中的hostname變量應該指向公有領域而不是數據庫,儘管 –

+0

是的,firefly.yml中的'hostname'是用於公共領域的url。 'host'是database.yml應該指向數據庫服務器。在這個例子中,這被假定爲localhost,但在生產中很少會如此。如果您運行'heroku config'並獲取HEROKU_POSTGRESQL_NAVY_URL的值並將其添加爲DATABASE_URL(如果它不存在),則它也將使其更容易移植。如果DATABASE_URL不存在,我可以使用我的所有應用程序。 – iain

+1

感謝您的幫助。在與螢火蟲開發者交談後,似乎2.0尚未準備好生產。我現在順利使用https://github.com/ariejan/firefly-heroku。 –