我已经成功部署,但是当我运行我的应用程序时,我的浏览器中出现了这个错误。
这些是我的heroku日志所说的:
C:\Users\Shekhar\heroku>heroku logs
2013-09-18T19:50:39.552663+00:00 heroku[api]: Enable Logplex by shekharsumanrock
@gmail.com
2013-09-18T19:50:39.574021+00:00 heroku[api]: Release v2 created by shekharsuman
rock@gmail.com
2013-09-18T19:51:51+00:00 heroku[slug-compiler]: Slug compilation started
2013-09-18T19:52:12.810160+00:00 heroku[api]: Scale to web=1 by shekharsumanrock
@gmail.com
2013-09-18T19:52:12.838111+00:00 heroku[api]: Add PATH config by shekharsumanroc
k@gmail.com
2013-09-18T19:52:12.866467+00:00 heroku[api]: Release v3 created by shekharsuman
rock@gmail.com
2013-09-18T19:52:12.914733+00:00 heroku[api]: Deploy 36856b3 by shekharsumanrock
@gmail.com
2013-09-18T19:52:12.943415+00:00 heroku[api]: Release v4 created by shekharsuman
rock@gmail.com
2013-09-18T19:52:13+00:00 heroku[slug-compiler]: Slug compilation finished
2013-09-18T19:52:15.273489+00:00 heroku[web.1]: Starting process with command `n
ode app.js`
2013-09-18T19:52:15.912133+00:00 heroku[web.1]: Starting process with command `n
ode app.js`
2013-09-18T19:52:16.112156+00:00 app[web.1]: info: socket.io started
2013-09-18T19:52:16.112156+00:00 app[web.1]: Server running at http://localhost:
5000/
2013-09-18T19:52:19.292035+00:00 app[web.1]: Server running at http://localhost:
5000/
2013-09-18T19:52:19.292035+00:00 app[web.1]: info: socket.io started
2013-09-18T19:53:16.461372+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-18T19:53:16.461211+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2013-09-18T19:53:17.545639+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2013-09-18T19:53:17.545980+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-18T19:53:17.710781+00:00 heroku[web.1]: Process exited with status 137
2013-09-18T19:53:18.938730+00:00 heroku[web.1]: Process exited with status 137
2013-09-18T19:53:20.623319+00:00 heroku[web.1]: Starting process with command `n
ode app.js`
2013-09-18T19:53:22.046545+00:00 app[web.1]: info: socket.io started
2013-09-18T19:53:22.046545+00:00 app[web.1]: Server running at http://localhost:
5000/
2013-09-18T19:54:22.301236+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web
process failed to bind to $PORT within 60 seconds of launch
2013-09-18T19:54:22.301533+00:00 heroku[web.1]: Stopping process with SIGKILL
2013-09-18T19:54:24.052821+00:00 heroku[web.1]: Process exited with status 137
2013-09-18T19:53:17.722653+00:00 heroku[web.1]: State changed from crashed to st
arting
2013-09-18T19:53:17.721912+00:00 heroku[web.1]: State changed from starting to c
rashed
2013-09-18T19:54:35.879665+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path=/ host=stark-temple-8404.herokuapp.com fwd="117.198.13.71"
dyno= connect= service= status=503 bytes=
2013-09-18T19:54:36.881441+00:00 heroku[router]: at=error code=H10 desc="App cra
shed" method=GET path=/favicon.ico host=stark-temple-8404.herokuapp.com fwd="117
.198.13.71" dyno= connect= service= status=503 bytes=
我在做什么错?
- - - -编辑 - - - -
app.js 文件
var app = require('http').createServer(handler)
, io = require('socket.io').listen(app)
, fs = require('fs')
function handler(req, res) {
if ('GET' == req.method && '/images' == req.url.substr(0, 7) && '.jpg' == req.url.substr(-4)) {
fs.stat(__dirname + req.url, function (err, stat) {
if (err || !stat.isFile()) {
res.writeHead(404);
res.end('Not Found');
return;
}
serve(__dirname + req.url, 'application/jpg');
});
}
else if ('GET' == req.method && '/' == req.url) {
serve(__dirname + '/index.html', 'text/html');
}
else if ('GET' == req.method && '.css' == req.url.substr(-4)) {
serve(__dirname + req.url, 'text/css');
}
else if ('GET' == req.method && '.ico' == req.url.substr(-4)) {
console.log("ICON has been called");
serve(__dirname + req.url, 'image/x-icon');
}
else if ('GET' == req.method && '.js' == req.url.substr(-3)) {
serve(__dirname + req.url, 'application/javascript');
}
else if ('GET' == req.method && '.png' == req.url.substr(-4)) {
serve(__dirname + req.url, 'image/png');
}
else {
res.writeHead(404);
res.end('Not found');
}
function serve (path, type) {
res.writeHead(200, { 'Content-Type': type });
fs.createReadStream(path).pipe(res);
}
};
console.log('Server running at http://localhost:5000/');
app.listen(5000);
io.configure(function () {
io.set("transports", ["xhr-polling"]);
io.set("polling duration", 10);
});
io.sockets.on('connection', function (socket) {
io.sockets.emit('this', { will: 'be received by everyone'}); //This will be received by everyone
socket.emit('news', { hello: 'world' }); //This will be received by none but one
socket.on('my other event', function (data) {
console.log(data);
});
socket.on('disconnect', function () {
io.sockets.emit('user disconnected');
});
socket.broadcast.emit('user connected'); //This will be received by everyone but one who initiates it
socket.on('set nickname', function (name) {
socket.set('nickname', name, function () {
socket.emit('ready');
});
});
socket.on('msg', function () {
socket.get('nickname', function (err, name) {
console.log('Chat message by ', name);
});
});
});
index.html 文件
<!doctype html>
<html>
<head>
<meta charset="utf-8">
<title>YAY!!</title>
<script src="/socket.io/socket.io.js"></script>
<link href="style.css" rel="stylesheet" type="text/css">
<script>
//var socket = io.connect('http://localhost');
var socket = io.connect(window.location.hostname);
socket.on('news', function (data) {
console.log(data);
socket.emit('my other event', { my: 'data' });
});
socket.on('this', function(data) {
console.log("This has been received "+data.will);
});
socket.emit('set nickname','Shekhar');
socket.on('ready', function(data) {
console.log("Name Set");
});
</script>
</head>
<body>
<div id="box1">What's up?</div>
</body>
</html>