Postgresql Postgres和Sequelize的Heroku部署问题

Postgresql Postgres和Sequelize的Heroku部署问题,postgresql,heroku,deployment,environment-variables,sequelize.js,Postgresql,Heroku,Deployment,Environment Variables,Sequelize.js,我正在尝试将我的应用程序部署到Heroku。它在本地运行时工作得非常好。从我部署它(通过github集成进行部署)的那一刻起,我就收到了通用应用程序错误屏幕。下面是我的heroku日志。这些实际上运行了三次,但我没有必要把同样的东西发布三次。它们总是以以下内容结束: 2017-05-02T14:59:26.033702+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-

我正在尝试将我的应用程序部署到Heroku。它在本地运行时工作得非常好。从我部署它(通过github集成进行部署)的那一刻起,我就收到了通用应用程序错误屏幕。下面是我的heroku日志。这些实际上运行了三次,但我没有必要把同样的东西发布三次。它们总是以以下内容结束:

2017-05-02T14:59:26.033702+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=calm-crag-40902.herokuapp.com request_id=6b64883e-9697-4d58-84d9-2f173d5b4cb1 fwd="70.
54.76.222" dyno= connect= service= status=503 bytes= protocol=https
2017-05-02T14:59:27.425435+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=calm-crag-40902.herokuapp.com request_id=d3719d8f-4670-4621-a044-a511ee6884
10 fwd="70.54.76.222" dyno= connect= service= status=503 bytes= protocol=https
这将在每个连续错误屏幕后打印2到4次。第一个错误是关于.env文件未运行,第二个错误是试图连接到sequelize。我的主要关注点是整理.env,因为如果整理好了,至少应用程序会显示我的应用程序是可见的

.env错误:

{ Error: ENOENT: no such file or directory, open '.env'
2017-05-02T16:09:39.622865+00:00 app[web.1]:     at Error (native)
2017-05-02T16:09:39.622866+00:00 app[web.1]:     at Object.fs.openSync (fs.js:641:18)
2017-05-02T16:09:39.622867+00:00 app[web.1]:     at Object.fs.readFileSync (fs.js:509:33)
2017-05-02T16:09:39.622867+00:00 app[web.1]:     at Object.config (/app/node_modules/dotenv/lib/main.js:30:37)
2017-05-02T16:09:39.622868+00:00 app[web.1]:     at Object.<anonymous> (/app/server.js:3:19)
2017-05-02T16:09:39.622869+00:00 app[web.1]:     at Module._compile (module.js:570:32)
2017-05-02T16:09:39.622869+00:00 app[web.1]:     at Object.Module._extensions..js (module.js:579:10)
2017-05-02T16:09:39.622870+00:00 app[web.1]:     at Module.load (module.js:487:32)
2017-05-02T16:09:39.622871+00:00 app[web.1]:     at tryModuleLoad (module.js:446:12)
2017-05-02T16:09:39.622871+00:00 app[web.1]:     at Function.Module._load (module.js:438:3) errno: -2, code: 'ENOENT', syscall: 'open', path: '.env' }
2017-05-02T16:09:40.242885+00:00 app[web.1]: Unhandled rejection
config.json:

{
  "development": {
    "username": "",
    "password": "",
    "database": "late_file",
    "host": "127.0.0.1",
    "dialect": "postgres"
  },
  "test": {
    "username": "",
    "password": "",
    "database": "database_test",
    "host": "127.0.0.1",
    "dialect": "postgres"
  },
  "production": {
    "use_env_variable": "DATABASE_URL",
    "dialect": "postgres"
  }
}
.env,修改为排除特定事物的名称

DB_HOST=localhost
DB_USER=
DB_PASS=
DB_NAME=
DB_SSL=true if heroku
DB_PORT=5432
DATABASE_URL=postgres://appropriate/url
server.js的适用部分

const pg = require('pg');

pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL, function(err, client) {
  if (err) throw err;
  console.log('Connected to postgres! Getting schemas...');

  client
    .query('SELECT table_schema,table_name FROM information_schema.tables;')
    .on('row', function(row) {
      console.log(JSON.stringify(row));
    });
});
任何帮助都将不胜感激! 提前感谢任何提供支持的人

布兰登

我正在Heroku上运行一个应用程序,使用JAWS_DB和MySQL,但在其他方面都是相同的config.json和index.js。在Heroku上的例子中,“if(config.use_env_variable){const sequelize=new sequelize(process.env[config.use_env_variable])”语句连接到数据库时没有错误。日志似乎指向server.js中出现故障的“pg.connect”。我不清楚(没有看到其余代码)为什么需要在index.js中连接到数据库,然后在server.js中再次连接。如果可以从pg.connect中删除连接并尝试仅使用index.js中的连接运行,则可能会停止此错误

DB_HOST=localhost
DB_USER=
DB_PASS=
DB_NAME=
DB_SSL=true if heroku
DB_PORT=5432
DATABASE_URL=postgres://appropriate/url
const pg = require('pg');

pg.defaults.ssl = true;
pg.connect(process.env.DATABASE_URL, function(err, client) {
  if (err) throw err;
  console.log('Connected to postgres! Getting schemas...');

  client
    .query('SELECT table_schema,table_name FROM information_schema.tables;')
    .on('row', function(row) {
      console.log(JSON.stringify(row));
    });
});