【问题标题】:Dancer2 app with Postgresql on Heroku在 Heroku 上使用 Postgresql 的 Dancer2 应用程序
【发布时间】:2016-06-30 10:36:59
【问题描述】:

我正在尝试在 Heroku 上部署一个使用 Postgresql 的小型 Dancer2 应用程序。 到目前为止,我试图接近: a) 我输入了heroku addons:add heroku-postgresql 手动创建的所有表,并授予我在heroku db 连接设置中找到的默认所有者女巫的权限。然后我将以下连接设置添加到我的 config.yml 文件中:

DBIC:
     d1ofgde:
       dsn:  'dbi:Pg:dbname=d1ofgde'
       user: 'ygcexhxtprm'
       password: 'izU2xTVDfd5T5Byy4M4Xhk'
       host: 'ec2-54-244-50-186.compute-1.amazonaws.com'
       port: 5432
       options:
         RaiseError: 1
         PrintError: 1
       schema_class: 'My::Schema

这失败了。

b) 我尝试使用以下命令将本地 postgres 数据库推送到 heroku:

PGUSER=test PGPASSWORD=test heroku pg:push mytestdb DATABASE_URL postgres://ygcexmzlhxtprm:izU2xTVDfd5RekzT5Byy4M4Xhk@ec2-54-243-50-185.compute-1.amazonaws.com:5432/d1ofgdng49tf0e --app  lit-mesa-10053

推手出错:

:pg_restore: [archiver (db)] could not execute query: ERROR:  must be owner of extension plpgsql
    Command was: COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language

但是当我登录我的 heroku postgres 时,我看到了里面的表格。

在这两种情况下,我在 config.yml 中的连接设置都使用了相同的结构。并得到了同样的错误信息:

2016-06-30T10:01:59.918775+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-mesa-10053.herokuapp.com request_id=99195ea6-fb7e-488c-93e8-2b7b5e306432 fwd="89.122.156.100" dyno= connect= service= status=503 bytes=
2016-06-30T10:02:00.403773+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=lit-mesa-10053.herokuapp.com request_id=dae4956e-954c-498b-8a32-e8ef8dc01c43 fwd="89.122.156.100" dyno= connect= service= status=503 bytes=
2016-06-30T10:12:07.295999+00:00 heroku[web.1]: State changed from crashed to starting
2016-06-30T10:12:14.677356+00:00 app[web.1]: Error while loading /app/app.psgi: The schema mytestdb is not configured at /app/local/lib/perl5/DBICx/Sugar.pm line 52, <DATA> line 1.
2016-06-30T10:12:14.677382+00:00 app[web.1]: Compilation failed in require at /app/app.psgi line 11, <DATA> line 1.
2016-06-30T10:12:15.886678+00:00 heroku[web.1]: Process exited with status 255
2016-06-30T10:12:20.228220+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=lit-mesa-10053.herokuapp.com request_id=36a8291d-fce1-485e-979c-986db9cbf9b7 fwd="89.122.156.100" dyno= connect= service= status=503 bytes=

【问题讨论】:

    标签: postgresql perl heroku dancer


    【解决方案1】:

    所以我用这段代码修复了我的错误:在 myapp.pm 我添加了这一行:

        my $env_url = $ENV{MYAPP_DB_DSN};
        my $env_user = $ENV{MYAPP_DB_USERNAME};
        my $env_password = $ENV{MYAPP_DB_PASSWORD};
    my $schema = My::Schema->connect("$env_url;user=$env_user;password=$env_password");
    

    然后用heroku config:set我给了值

    MyAPP_DB_DSN='dbi:Pg:dbname=mydb; host=myherokuhost'; port=5432'
    MYAPP_DB_USERNAME=myusername  
    MYAPP_DB_PASSWORD=mypass
    

    现在可以使用了

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-03-04
      • 2013-01-08
      • 2012-06-22
      • 1970-01-01
      • 2012-09-01
      • 1970-01-01
      • 2020-11-12
      • 2013-07-29
      相关资源
      最近更新 更多