【发布时间】:2014-09-04 08:23:17
【问题描述】:
我正在尝试在 Heroku 上部署我的应用程序。我已按照以下说明进行操作:https://devcenter.heroku.com/articles/getting-started-with-nodejs,启用 websockets,但是当我运行 $heroku open 时,我进入了错误页面。
这是我从 heroku 获得的日志:
2014-07-14T11:41:27.331343+00:00 heroku[web.1]: Starting process with command `node index.js`
2014-07-14T11:41:28.431660+00:00 app[web.1]: info: socket.io started
2014-07-14T11:42:27.710153+00:00 heroku[web.1]: Error R10 (Boot timeout) -> Web process failed to bind to $PORT within 60 seconds of launch
2014-07-14T11:42:27.710206+00:00 heroku[web.1]: Stopping process with SIGKILL
2014-07-14T11:42:28.915226+00:00 heroku[web.1]: Process exited with status 137
2014-07-14T11:42:28.927884+00:00 heroku[web.1]: State changed from starting to crashed
这是我的应用的 index.js 文件:
// Import the Express module
var express = require('express');
// Import the 'path' module (packaged with Node.js)
var path = require('path');
// Create a new instance of Express
var app = express();
// Import Anagrammatix game file.
var agx = require('./game');
// Create a simple Express application
app.configure(function() {
// Turn down the logging activity
app.use(express.logger('dev'));
// Serve static html, js, css, and image files from the 'public' directory
app.use(express.static(path.join(__dirname,'public')));
});
// Create a Node.js based http server on port 8080
var server = require('http').createServer(app).listen(8080);
// Create a Socket.IO server and attach it to the http server
var io = require('socket.io').listen(server);
// Reduce the logging output of Socket.IO
io.set('log level',1);
// Listen for Socket.IO Connections. Once connected, start the game logic.
io.sockets.on('connection', function (socket) {
//console.log('client connected');
agx.initGame(io, socket);
});
我使用的 node_modules 是: - 表示 - mysql - socket.io
你知道我应该改变什么来让应用正常工作吗?如果您需要我提供更多信息,请告诉我。
谢谢!
【问题讨论】:
标签: node.js heroku deployment socket.io