我在英雄上手动部署了一个应用程序(之前从未完成过,只是将它连接到我的github存储库)。它说成功部署但我得到了错误:
An error occurred in the application and your page could not be served. Please
try again in a few moments.
If you are the application owner, check your logs for details.
我的日志是:
2016-10-17T02:39:38.026918+00:00 app[web.1]: at Function.Module._load (module.js:314:12)
2016-10-17T02:39:38.026919+00:00 app[web.1]: at Module.require (module.js:367:17)
2016-10-17T02:39:38.026919+00:00 app[web.1]: at require (internal/module.js:20:19)
2016-10-17T02:39:38.026920+00:00 app[web.1]: at Object.<anonymous> (/app/server/db/index.js:2:10)
2016-10-17T02:39:38.026921+00:00 app[web.1]: at Module._compile (module.js:413:34)
2016-10-17T02:39:38.026921+00:00 app[web.1]: at loader (/app/node_modules/babel-register/lib/node.js:144:5)
2016-10-17T02:39:38.026922+00:00 app[web.1]: at Object.require.extensions.(anonymous function) [as .js] (/app/node_modules/babel-register/lib/node.js:154:7)
2016-10-17T02:39:38.026923+00:00 app[web.1]: at Module.load (module.js:357:32)
2016-10-17T02:39:38.116826+00:00 heroku[web.1]: State changed from starting to crashed
2016-10-17T02:39:38.917261+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pokemartapp.herokuapp.com request_id=90de2bee-e747-4901-8554-90aa3d57c1f1 fwd="68.105.253.103" dyno= connect= service= status=503 bytes=
2016-10-17T02:43:14.022540+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=pokemartapp.herokuapp.com request_id=589b8bf6-e786-43d6-b6e8-d9b09dca7586 fwd="68.105.253.103" dyno= connect= service= status=503 bytes=
我的服务器:
var chalk = require('chalk');
var db = require('./db');
var server = require('http').createServer();
var createApplication = function () {
var app = require('./app')(db);
server.on('request', app); // Attach the Express application.
require('./io')(server); // Attach socket.io.
};
var startServer = function () {
var PORT = process.env.PORT || 1337;
server.listen(PORT, function () {
console.log(chalk.blue('Server started on port', chalk.magenta(PORT)));
});
};
db.sync().then(createApplication).then(startServer).catch(function (err) {
console.error(chalk.red(err.stack));
});
我的procfile:
web: node server/start.js
server / env / index.js:
var path = require('path'); var devConfigPath = path.join(__dirname, './development.js');
var productionConfigPath = path.join(__dirname, './production.js');
var testConfigPath = path.join(__dirname, './testing.js');
if (process.env.NODE_ENV === 'production') { module.exports =
require(productionConfigPath); }
else if (process.env.NODE_ENV === 'testing') { module.exports = require(testConfigPath); }
else { module.exports = require(devConfigPath); }
这是什么意思?我研究过具有相同问题的帖子和提出的答案,但没有什么真正有帮助..
答案 0 :(得分:0)
您可以尝试setting the Node and NPM versions与本地使用的相同(工作地点)。
另外请确保您没有错过dev依赖项,因为除非explicitly configure to do so,否则Heroku不会安装它们。
更新:
从您的评论中看来,当您在Heroku等生产环境中运行代码时,数据库URL将从名为return _context.Section.Include(x => x.Leagues.Select(y => y.Games.Where(v=>v.GameStart > DateTime.Now))).ToList();
的环境变量中获取。您可以在DATABASE_URI
上更改此变量以匹配添加插件时添加到应用程序的env var的键,或者您可以创建具有所需值的环境变量。有关更多信息,请阅读this