0

https://github.com/twilio/hurl

我无法通过自述文件中的步骤在 Heroku 上运行服务器。

我做的步骤:

git clone git://github.com/twilio/hurl
cd hurl
gem install bundler
bundle install
heroku create
git push heroku master
heroku open

使用heroku logs我看到连接到的错误PG

"/app/app/models/db.rb:16:in `initialize': could not connect to server: Connection refused (PG::Error)"

请帮助我做错了什么..

更新:

file:`db.rb`
    15      class PostgresDB < AbstractDB
    16        CONN = PG::Connection::new(
    17         ENV.fetch("POSTGRES_HOST", "localhost"),
    18          ENV.fetch("POSTGRES_PORT", 5432), 
    19          :dbname => ENV.fetch("POSTGRES_DATABASE", "hurls"),
    20          :user => ENV.fetch("POSTGRES_USER", "postgres"),
    21          :password => ENV.fetch("POSTGRES_PASSWORD", "postgres")
    22        )

从 postgresql 的配置 heroku 插件服务器更改了详细信息并收到此错误:

Starting process with command `bundle exec rackup config.ru -p 16112`
2013-02-14T07:55:41+00:00 app[web.1]: LINE 1: INSERT INTO hurls VALUES ($1::varchar, $2::bytea)
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb:1137:in `new'
2013-02-14T07:55:41+00:00 app[web.1]: /app/app/models/db.rb:39:in `exec': ERROR:  relation "hurls" does not exist (PG::Error)
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/app/app.rb:35:in `initialize'
2013-02-14T07:55:41+00:00 app[web.1]:   from config.ru:1:in `new'
2013-02-14T07:55:41+00:00 app[web.1]:                     ^
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/sinatra-1.1.0/lib/sinatra/base.rb:1137:in `new'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/bin/rackup:4:in `<top (required)>'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/app/helpers.rb:69:in `each'
2013-02-14T07:55:41+00:00 app[web.1]:   from config.ru:13:in `block in <main>'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:162:in `app'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `load'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:248:in `wrapped_app'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/bin/rackup:19:in `<main>'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:46:in `instance_eval'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:100:in `start'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/app/helpers.rb:70:in `block in setup_default_hurls'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/app/helpers.rb:69:in `setup_default_hurls'
2013-02-14T07:55:41+00:00 app[web.1]:   from config.ru:1:in `<main>'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/app/app.rb:245:in `save_hurl'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:46:in `initialize'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:35:in `eval'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/app/models/db.rb:39:in `save'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/builder.rb:35:in `parse_file'
2013-02-14T07:55:41+00:00 app[web.1]:   from /app/vendor/bundle/ruby/1.9.1/gems/rack-1.2.1/lib/rack/server.rb:213:in `start'
2013-02-14T07:55:42+00:00 heroku[web.1]: Process exited with status 1
2013-02-14T07:55:42+00:00 heroku[web.1]: State changed from starting to crashed
2013-02-14T07:55:43+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path=/ host=my-hurl-*****.herokuapp.com fwd=95.65.21.178 dyno= queue= wait= connect= service= status=503 bytes=

有人实现了正常的heroku服务器吗?

4

2 回答 2

1

解决了

使用以下方法添加所有配置变量:

$ heroku config:add POSTGRES_DATABASE=your_database
$ heroku config:add POSTGRES_HOST=your_host
$ heroku config:add POSTGRES_USER=your_user
$ heroku config:add POSTGRES_PASSWORD=your_password
$ heroku config:add POSTGRES_PORT=5432

或在一行中: $ heroku config:add POSTGRES_DATABASE=your_database POSTGRES_HOST=your_host POSTGRES_USER=your_user POSTGRES_PASSWORD=your_password POSTGRES_PORT=5432

否则手动创建表:

$ heroku pg:psql
create table users (id character(40), content bytea);
create table hurls (id character(40), content bytea);
于 2013-02-15T09:13:39.827 回答
0

除了由 rails 控制台生成的 config 目录中的文件之外,gemfile 也需要正确编辑才能与 postgresql 一起使用,通常 rails 生成 db.rb 以使用 sqlite3 并且 gemfile 中也提到了相同的 db,它们都需要工作使用 postgresql,因为 heroku 使用 postgres,希望它可能会有所帮助。

于 2013-02-14T13:19:17.023 回答