我读了很多书,我认为这个问题主要与端口号有关。在这个错误之前,我在本地设置自己的端口,但在谷歌搜索了几次之后,我发现我必须分配Heroku提供的端口号,所以我继续添加应用程序。监听(process.env.PORT | | 5000)
到我的
服务器。js
但根据我的heroku日志,我认为端口仍然存在问题。我会感谢你的帮助。谢谢:)
var express = require('express'),
app = express();
//app.set('port', (process.env.PORT || 5000));
/* EXPRESS 3.0
app.configure(function () {
app.use(express.static(__dirname, '/'));
});
*/
// EXPRESS 4.0
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
// configure stuff here
app.use(express.static(__dirname + '/'));
}
/*EXPRESS 3.0
app.get('/customers/:id', function(req, res) {
var customerId = parseInt(req.params.id);
var data = {};
for (var i = 0, len = customers.length; i < len; i++) {
if (customers[i].id === customerId) {
data = customer[i];
break;
}
}
res.json(data)
});
*/
//EXPRESS 4.0
app.route('/customers/:id')
.get(function(req, res) {
var customerId = parseInt(req.params.id);
var data = {};
for (var i = 0, len = customers.length; i < len; i++) {
if (customers[i].id === customerId) {
data = customers[i];
break;
}
}
res.json(data)
})
/* EXPRESS 3.0
app.get('/customers', function(req, res) {
res.json(customers);
});
*/
//EXPRESS 4.0
app.route('/customers')
.get (function(req, res) {
return res.json(customers);
})
//this was missing!!
app.route('/orders')
.get(function(req, res) {
var a = customers;
return res.json(a.map(function(item) {
return item.orders[0];
}));
})
/*
app.listen(3000);
*/
/***
Heroku dynamically assigns your app a port, so you can't set the port to a fixed number. Heroku adds the port to the env, so you can pull it from there.
*/
app.listen(process.env.PORT || 5000);
console.log('Express listening on port ' + process.env.PORT);
var customers = [
{
id: 1,
joined: '2005-09-07',
name: 'Floyd',
city: 'Brooklyn',
orderTotal: '43.1299',
orders: [
{
id: 1,
product: 'Pencils',
total: 9.9956
}
]
},
{
id: 2,
joined: '2005-09-07',
name: 'Jason',
city: 'Cleveland',
orderTotal: '89.8933',
orders: [
{
id: 1,
product: 'iPad',
total: 20.9956
}
]
},
{
id: 3,
joined: '1999-08-27',
name: 'Jade',
city: 'Wroclaw',
orderTotal: '77.0092',
orders: [
{
id: 1,
product: 'Pillows',
total: 12.2311
}
]
},
{
id: 4,
joined: '2015-09-01',
name: 'David',
city: 'Accra',
orderTotal: '13.8465',
orders: [
{
id: 1,
product: 'Beats Pill',
total: 11.4782
}
]
},
{
id: 5,
joined: '2001-01-18',
name: 'Doyet',
city: 'Paris',
orderTotal: '23.9930',
orders: [
{
id: 1,
product: 'Serek',
total: 11.4782
}
]
}];
Heroku原木
siaw ~/Desktop/angularjshelloworld $ heroku logs
2015-09-04T01:58:16.070031+00:00 heroku[web.1]: Process exited with status 137
2015-09-04T01:58:16.087030+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-04T03:00:42.864087+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-04T03:00:45.736332+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T03:00:48.846167+00:00 app[web.1]: Express listening on port 3000
2015-09-04T03:01:45.855512+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-04T03:01:45.855512+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-04T03:01:46.716529+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-04T03:01:46.698294+00:00 heroku[web.1]: Process exited with status 137
2015-09-04T04:38:46.544960+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-04T04:38:48.655956+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T04:38:50.863631+00:00 app[web.1]: Express listening on port 3000
2015-09-04T04:39:49.016795+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-04T04:39:49.016534+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-04T04:39:49.882153+00:00 heroku[web.1]: Process exited with status 137
2015-09-04T04:39:49.898252+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-04T07:49:01.371443+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-04T07:49:03.864654+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T07:49:05.984160+00:00 app[web.1]: Express listening on port 3000
2015-09-04T07:50:04.146962+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-04T07:50:04.146962+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-04T07:50:04.994997+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-04T07:50:04.979032+00:00 heroku[web.1]: Process exited with status 137
2015-09-04T10:55:39.200532+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-04T10:55:39.200553+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-04T10:55:39.150765+00:00 heroku[api]: Release v9 created by siawmensah@gmail.com
2015-09-04T10:55:39.150572+00:00 heroku[api]: Deploy b7c65bc by siawmensah@gmail.com
2015-09-04T10:55:39.315718+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-04T10:55:42.086941+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T10:55:44.473394+00:00 app[web.1]: Express listening on port 3000
2015-09-04T10:56:42.344180+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-04T10:56:42.344409+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-04T10:56:43.130511+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-04T10:56:43.131379+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-04T10:56:43.118411+00:00 heroku[web.1]: Process exited with status 137
2015-09-04T10:56:45.574710+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T10:56:47.515411+00:00 app[web.1]: Express listening on port 3000
2015-09-04T10:57:46.106655+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2015-09-04T10:57:46.106732+00:00 heroku[web.1]: Stopping process with SIGKILL
2015-09-04T10:57:46.880841+00:00 heroku[web.1]: State changed from starting to crashed
2015-09-04T10:57:46.864748+00:00 heroku[web.1]: Process exited with status 137
2015-09-04T10:57:48.145151+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=122b26d1-0e5c-4b9e-a887-31cce7531826 fwd="78.88.252.85" dyno= connect= service= status=503 bytes=
2015-09-04T10:57:49.109952+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-mountain-6684.herokuapp.com request_id=71275557-49c0-45a3-9000-fc7192f9b243 fwd="78.88.252.85" dyno= connect= service= status=503 bytes=
2015-09-04T10:57:49.534153+00:00 heroku[router]: at=error code=H10 desc="App crashed" method=GET path="/favicon.ico" host=immense-mountain-6684.herokuapp.com request_id=866e2c82-e4fd-4354-a897-d12fb540bec8 fwd="78.88.252.85" dyno= connect= service= status=503 bytes=
2015-09-04T11:02:09.401257+00:00 heroku[api]: Release v10 created by siawmensah@gmail.com
2015-09-04T11:02:09.466496+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-04T11:02:09.466519+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-04T11:02:09.399764+00:00 heroku[api]: Deploy be4140a by siawmensah@gmail.com
2015-09-04T11:02:09.801809+00:00 heroku[web.1]: State changed from crashed to starting
2015-09-04T11:02:12.174299+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T11:02:15.235379+00:00 app[web.1]: Express listening on port 3000
2015-09-04T11:02:15.946514+00:00 heroku[web.1]: State changed from starting to up
2015-09-04T11:02:18.707201+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=cda497c2-4a89-47bd-a966-1bbc7f0eb89d fwd="78.88.252.85" dyno=web.1 connect=1ms service=29ms status=404 bytes=211
2015-09-04T11:02:27.101687+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=dc63715a-5797-466e-b36e-28690c9cd860 fwd="78.88.252.85" dyno=web.1 connect=1ms service=20ms status=404 bytes=211
2015-09-04T11:06:04.494169+00:00 heroku[api]: Deploy 0a02678 by siawmensah@gmail.com
2015-09-04T11:06:04.494288+00:00 heroku[api]: Release v11 created by siawmensah@gmail.com
2015-09-04T11:06:04.554874+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-04T11:06:04.554885+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-04T11:06:04.752759+00:00 heroku[web.1]: State changed from up to starting
2015-09-04T11:06:06.814554+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T11:06:07.310814+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-04T11:06:08.705139+00:00 heroku[web.1]: Process exited with status 143
2015-09-04T11:06:08.757441+00:00 app[web.1]: Express listening on port 3000
2015-09-04T11:06:09.218219+00:00 heroku[web.1]: State changed from starting to up
2015-09-04T11:06:20.708204+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=c8d050c8-ad1a-4721-9231-62c5a39452de fwd="78.88.252.85" dyno=web.1 connect=1ms service=15ms status=404 bytes=211
2015-09-04T11:11:49.383821+00:00 heroku[api]: Deploy 7d3f718 by siawmensah@gmail.com
2015-09-04T11:11:49.383935+00:00 heroku[api]: Release v12 created by siawmensah@gmail.com
2015-09-04T11:11:49.466101+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-04T11:11:49.466132+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-04T11:11:49.476376+00:00 heroku[web.1]: State changed from up to starting
2015-09-04T11:11:51.439862+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T11:11:51.616303+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-04T11:11:53.001229+00:00 heroku[web.1]: Process exited with status 143
2015-09-04T11:11:53.135287+00:00 app[web.1]: Express listening on port 3000
2015-09-04T11:11:53.680354+00:00 heroku[web.1]: State changed from starting to up
2015-09-04T11:12:01.974355+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=159267f7-a727-4fb1-998c-04e10a1f02e2 fwd="78.88.252.85" dyno=web.1 connect=0ms service=17ms status=404 bytes=211
2015-09-04T11:15:03.674781+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-04T11:15:03.674807+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-04T11:15:03.619420+00:00 heroku[api]: Deploy c9893f2 by siawmensah@gmail.com
2015-09-04T11:15:03.619545+00:00 heroku[api]: Release v13 created by siawmensah@gmail.com
2015-09-04T11:15:03.750480+00:00 heroku[web.1]: State changed from up to starting
2015-09-04T11:15:05.413926+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T11:15:06.551367+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-04T11:15:07.018219+00:00 heroku[web.1]: State changed from starting to up
2015-09-04T11:15:06.946226+00:00 app[web.1]: Express listening on port 3000
2015-09-04T11:15:08.041342+00:00 heroku[web.1]: Process exited with status 143
2015-09-04T11:15:08.120730+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=59fa1ce4-2d09-4f3b-91fd-fd1e9df50a48 fwd="78.88.252.85" dyno=web.1 connect=1ms service=16ms status=404 bytes=211
2015-09-04T11:17:43.511952+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=2b1b21f7-184d-4f08-9947-2abb11f71a80 fwd="78.88.252.85" dyno=web.1 connect=2ms service=6ms status=404 bytes=211
2015-09-04T11:18:23.537710+00:00 heroku[api]: Deploy dd0e60c by siawmensah@gmail.com
2015-09-04T11:18:23.537839+00:00 heroku[api]: Release v14 created by siawmensah@gmail.com
2015-09-04T11:18:23.458614+00:00 heroku[slug-compiler]: Slug compilation started
2015-09-04T11:18:23.458631+00:00 heroku[slug-compiler]: Slug compilation finished
2015-09-04T11:18:23.648871+00:00 heroku[web.1]: State changed from up to starting
2015-09-04T11:18:24.884774+00:00 heroku[web.1]: Starting process with command `node server.js`
2015-09-04T11:18:25.985675+00:00 app[web.1]: Express listening on port 41317
2015-09-04T11:18:26.494228+00:00 heroku[web.1]: State changed from starting to up
2015-09-04T11:18:26.646791+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2015-09-04T11:18:28.106828+00:00 heroku[web.1]: Process exited with status 143
2015-09-04T11:20:51.765434+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=8bcd68b1-a0de-4744-b44d-59ead272abda fwd="78.88.252.85" dyno=web.1 connect=0ms service=11ms status=404 bytes=211
2015-09-04T11:21:03.563517+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=c04834e1-beb9-41ee-9749-cbece8b436ac fwd="78.88.252.85" dyno=web.1 connect=1ms service=5ms status=404 bytes=211
2015-09-04T11:21:10.366666+00:00 heroku[router]: at=info method=GET path="/" host=immense-mountain-6684.herokuapp.com request_id=a9844e0c-7454-4dee-a691-0cbd511cafd3 fwd="78.88.252.85" dyno=web.1 connect=0ms service=2ms status=404 bytes=211
我用这个修复了它:
var env = process.env.NODE_ENV || 'development';
if ('development' == env) {
// configure stuff here
app.use(express.static(__dirname + '/'));
} else {
app.use(express.static(__dirname + '/'));
}
我知道有一个更漂亮的方法来写这个条件,但是你明白了。我稍后会修复它。它需要一个用于正式生产环境的路径。:)
问题似乎与webdynos有关,而不是您的应用程序。试着重新启动它。
以下是关于R10启动超时错误的文档。
R10-启动超时
一个web进程花了超过60秒的时间绑定到它分配的$PORT。当这种情况发生时,dyno的进程被杀死,dyno被认为是崩溃的。崩溃的dyno将根据dyno管理器的重启策略重新启动。
我正在heroku部署一个python脚本,它将在每
我正试图在heroku上部署我的服务器。我犯了这个错误: 这是我Java课: 我怎样才能解决这个问题? 谢谢你
我正试图将我的Spring Boot应用程序部署到Heroku,但我一直得到: 我已经看到了一些答案,这些答案告诉我这一点 在我的应用程序属性,但它仍然不工作。 我看不出我还能做什么,也没有进一步的输出可以提示我问题的根源。 有什么想法吗?
我找到了十几个用于设置监听端口的快速驱动应用程序的解决方案。但是我有一个不使用快递的应用程序,事实上也不听任何东西。成功运行60秒后,我得到一个
我正在部署一个带有CMD行的Docker映像: 在日志中,它看起来像: 出现以下错误: 我应该在配置中更改什么?