Heroku部署socketio错误

时间:2016-04-14 20:46:20

标签: express heroku deployment socket.io

我尝试将我的代码部署到Heroku以测试我的应用程序,端口有一些问题,但现在我被卡住了......

我的服务器代码是:

"use strict";

var fs          = require('fs');
var SQL         = require('sql.js');
var filebuffer  = fs.readFileSync('cards.sqlite');
var extend      = require('extend');
var express     = require('express');
var app         = express();
app.listen(process.env.PORT || 3000, function(){
    console.log("Express server listening on port %d in %s mode", this.address().port, app.settings.env);
});
var server      = require('http').Server(app);
var io          = require('socket.io')(server);
var users       = [];
var rooms       = [];
var userHelper  = new UserHelper(); //removed from file, irelevant
var roomHelper  = new RoomHelper(); //removed from file, irelevant
var cardService = new CardService(filebuffer);
io.on('connection', function (socket) {
    socket.on('set-user-name', function (name, callback) {
        if (userHelper.userExists(users, name)) {
            callback(false,null);
        } else {
            socket.user = new User(name, socket.id);
            users.push(socket.user);
            io.emit('user-join', socket.user);
            callback(true,socket.user);
        }
    });
    [removed code]
    socket.on('disconnect', function () {
        [removed code]
    });

});

从heroku终端我得到:

2016-04-14T20:39:27.331019+00:00 app[web.1]: Express server listening on port 7112 in production mode
2016-04-14T20:39:27.060785+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-04-14T20:39:29.307428+00:00 heroku[web.1]: Process exited with status 143
2016-04-14T20:41:32.806795+00:00 heroku[web.1]: State changed from up to starting
2016-04-14T20:41:32.806215+00:00 heroku[web.1]: Restarting
2016-04-14T20:41:34.420532+00:00 heroku[web.1]: Starting process with command `node index.js`
2016-04-14T20:41:36.598382+00:00 heroku[web.1]: Stopping all processes with SIGTERM
2016-04-14T20:41:37.812607+00:00 app[web.1]: Express server listening on port 22679 in production mode
2016-04-14T20:41:38.055004+00:00 heroku[web.1]: State changed from starting to up
2016-04-14T20:41:38.384013+00:00 heroku[web.1]: Process exited with status 143

编辑:尝试删除sqlite处理但仍然没有希望

0 个答案:

没有答案