在heroku上的socket.io + node.js [英] socket.io + node.js on heroku

查看:115
本文介绍了在heroku上的socket.io + node.js的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述



这就是app.js文件


$ b

我在编译一个socket.io应用程序时遇到了一些问题。 $ b

  var app = require('express')。createServer()
,io = require('socket.io')。listen(app.listen(process .env.PORT || 5000));

app.get('/',function(req,res){
res.sendfile(__ dirname +'/index.html');
});

var users = [];
$ b $ io.configure(function(){
io.set(transports,[xhr-polling]);
io.set(polling duration, 10);
});

io.sockets.on('connection',function(socket){

socket.on('message',function(data,time,username){


socket.broadcast.emit('message',data,time,username);

socket.emit('message',data,time,username,true );
});

socket.on('connected',function(username){

socket.nick = username;

users.push(用户名);

io.sockets.emit('user_connected',users);
});

socket.on(' disconnect()函数(){

users.splice(users.indexOf(socket.nick),1);

socket.broadcast.emit('updated_user_list',users );
});

});

package.json

  {
name:application-name,
version:0.0.1,
private:true,
脚本:{
start:node app
},
engines:{
node:0.8.x,
npm:1.1.x
},
依赖关系:{
express:3.0.0rc1,
jade:*,
socket.io:〜0.9.8
}
}

这就是将它推到heroku时的错误

  [gaggina:〜/ Desktop / socket2]→git push heroku master 
计数对象:1016,完成。
使用多达4个线程的增量压缩。
压缩对象:100%(892/892),完成。
写作对象:100%(1016/1016),3.90 MiB | 104 KiB / s,完成。
共计1016(增量74),重用0(增量0)

-----> Heroku接收推送
-----> Node.js应用检测到
----->解析引擎版本
使用Node.js版本:0.8.3
使用npm版本:1.1.41
----->获取Node.js二进制文件
----->将节点卖给slug
----->使用npm
安装依赖关系npm WARN package.json application-name@0.0.1找不到README.md文件!
npm WARN package.json jade@0.26.3找不到README.md文件!
npm WARN package.json application-name@0.0.1找不到README.md文件!
npm WARN package.json jade@0.26.3找不到README.md文件!
npm WARN package.json connect@2.4.1找不到README.md文件!
npm WARN package.json methods@0.0.1找不到README.md文件!
npm WARN package.json hiredis@0.1.14找不到README.md文件!

> ws@0.4.21 install /tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
>节点install.js

[ws v0.4.21]试图编译快速的原生扩展。
[ws v0.4.21]原生扩展编译成功!

> hiredis@0.1.14 preinstall /tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis
> make || gmake

cd deps / hiredis&& make static $ b $ make [1]:进入目录`/tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis/deps/hiredis'
make [1]:无法完成为`静态'。
make [1]:离开目录`/tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis/deps/hiredis'
node-waf configure build
设置srcdir to:/tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis
将blddir设置为:/tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build
检查程序g ++或c ++:/ usr / bin / g ++
检查程序cpp:/ usr / bin / cpp
检查程序ar:/ usr / bin / ar
检查对于程序ranlib:/ usr / bin / ranlib
检查g ++:ok
检查节点路径:未找到
检查节点前缀:ok / tmp / node-node-de4o
'configure'完成成功ssfully(1.834s)
Waf:进入目录`/Users/gaggina/Desktop/socket2/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
Waf:离开目录`/ Users /gaggina/Desktop/socket2/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
Traceback(最近的最后一次调用):
File/ tmp / node-node-de4o / bin / node-waf,第16行,在< module>
Scripting.prepare(t,os.getcwd(),VERSION,wafdir)
文件/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py ,第145行,准备
prepare_impl(t,cwd,ver,wafdir)
文件/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py第135行,在prepare_impl
main()
文件/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py,行188,在main
fun(ctx)
创建
文件/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py,第386行返回build_impl( bld)
文件/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py,第405行,在build_impl中
bld.compile()
文件/tmp/node-node-de4o/bin/../lib/node/wafadmin/Build.py,第268行,编译
os.chdir(self.bldnode.abspath())
OSError:[Errno 2]没有这样的文件或目录:'/ Users / gaggina / Desktop / socket2 / node_modules / socket。 io / node_modules / redis / node_modules / hiredis / build'
make:*** [all]错误1
sh:gmake:找不到
npm ERR! hiredis@0.1.14预安装:`make || gmake`
npm ERR! `sh-cmake || gmake`失败,127
npm ERR!
npm ERR! hiredis@0.1.14预安装脚本失败。
npm ERR!这很可能是hiredis包
npm ERR!的问题!而不是npm本身。
npm ERR!告诉作者这在你的系统上失败了:
npm ERR! make || gmake
npm ERR!您可以通过以下方式获得他们的信息:
npm ERR! npm owner ls hiredis
npm ERR!上面可能还有其他日志记录输出。

npm ERR!系统Linux 2.6.32-343-ec2
npm ERR!命令/ tmp / node-node-de4o / bin / node/tmp/node-npm-Xp2N/cli.jsrebuild
npm ERR! cwd / tmp / build_3gzqoe2cjr234
npm ERR! node -v v0.8.3
npm ERR! npm -v 1.1.41
npm ERR!代码ELIFECYCLE
npm ERR!堆栈错误:hiredis@0.1.14预安装:`make || gmake`
npm ERR! sh-cmake || gmake`失败,返回127
npm ERR!在ChildProcess上堆叠。< anonymous> (/tmp/node-npm-Xp2N/lib/utils/exec.js:56:20)
npm ERR!堆栈在ChildProcess.EventEmitter.emit(events.js:91:17)
npm ERR!堆栈在Process._handle.onexit(child_process.js:674:10)
npm ERR!
npm ERR!附加的日志记录细节可以在以下位置找到:
npm ERR! /tmp/build_3gzqoe2cjr234/npm-debug.log
npm ERR!不好的代码0
!无法用npm
重建依赖关系! Heroku推送被拒绝,未能编译Node.js应用程序

到git@heroku.com:沸腾超越2052.git
! [remote rejected] master - > master(pre-receive hook refused)
错误:未能将一些文件推送到'git@heroku.com:boiling-beyond-2052.git'
[gaggina:〜/ Desktop / socket2]→cat /tmp/build_3gzqoe2cjr234/npm-debug.log
cat:/tmp/build_3gzqoe2cjr234/npm-debug.log:没有这样的文件或目录


解决方案

Heroku未能创建hiredis。原因是hiredis(node.js模块)依赖于hiredis(C库),它需要GNU make,这在你的slu not上不可用。



问题是,为什么NPM试图建立hiredis,而它不在你的依赖关系?



你应该检查hiredis是否出现在你项目的任何地方( grep - R hiredis。)。另一种可能是Heroku试图为所有node.js应用程序提供redis?



我会检查Heroku的支持。


I'm having some issues in compiling a socket.io app on heroku.

Thats the app.js file

var app = require('express').createServer()
   , io = require('socket.io').listen(app.listen(process.env.PORT || 5000));

app.get('/', function (req, res) {
    res.sendfile(__dirname + '/index.html');
});

var users = [];

  io.configure(function () { 
  io.set("transports", ["xhr-polling"]); 
  io.set("polling duration", 10); 
});

io.sockets.on('connection', function (socket) {

  socket.on('message',function(data,time,username){


    socket.broadcast.emit('message',data,time,username);

    socket.emit('message',data,time,username,true);
  });

  socket.on('connected',function(username){

    socket.nick = username;

    users.push(username);

    io.sockets.emit('user_connected',users);
  });

  socket.on('disconnect',function(){

    users.splice(users.indexOf(socket.nick), 1);

    socket.broadcast.emit('updated_user_list',users);
  });

});

package.json

{
  "name": "application-name",
  "version": "0.0.1",
  "private": true,
  "scripts": {
    "start": "node app"
  },
  "engines": {
    "node": "0.8.x",
    "npm":  "1.1.x"
  },
  "dependencies": {
    "express": "3.0.0rc1",
    "jade": "*",
    "socket.io": "~0.9.8"
  }
}

And that's the error when pushing it to heroku

[gaggina:~/Desktop/socket2]→git push heroku master
Counting objects: 1016, done.
Delta compression using up to 4 threads.
Compressing objects: 100% (892/892), done.
Writing objects: 100% (1016/1016), 3.90 MiB | 104 KiB/s, done.
Total 1016 (delta 74), reused 0 (delta 0)

-----> Heroku receiving push
-----> Node.js app detected
-----> Resolving engine versions
       Using Node.js version: 0.8.3
       Using npm version: 1.1.41
-----> Fetching Node.js binaries
-----> Vendoring node into slug
-----> Installing dependencies with npm
       npm WARN package.json application-name@0.0.1 No README.md file found!
       npm WARN package.json jade@0.26.3 No README.md file found!
       npm WARN package.json application-name@0.0.1 No README.md file found!
       npm WARN package.json jade@0.26.3 No README.md file found!
       npm WARN package.json connect@2.4.1 No README.md file found!
       npm WARN package.json methods@0.0.1 No README.md file found!
       npm WARN package.json hiredis@0.1.14 No README.md file found!

       > ws@0.4.21 install /tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/socket.io-client/node_modules/ws
       > node install.js

       [ws v0.4.21] Attempting to compile blazing fast native extensions.
       [ws v0.4.21] Native extension compilation successful!

       > hiredis@0.1.14 preinstall /tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis
       > make || gmake

       cd deps/hiredis && make static
       make[1]: Entering directory `/tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis/deps/hiredis'
       make[1]: Nothing to be done for `static'.
       make[1]: Leaving directory `/tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis/deps/hiredis'
       node-waf configure build
       Setting srcdir to                        : /tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis 
       Setting blddir to                        : /tmp/build_3gzqoe2cjr234/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build 
       Checking for program g++ or c++          : /usr/bin/g++ 
       Checking for program cpp                 : /usr/bin/cpp 
       Checking for program ar                  : /usr/bin/ar 
       Checking for program ranlib              : /usr/bin/ranlib 
       Checking for g++                         : ok  
       Checking for node path                   : not found 
       Checking for node prefix                 : ok /tmp/node-node-de4o 
       'configure' finished successfully (1.834s)
       Waf: Entering directory `/Users/gaggina/Desktop/socket2/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
       Waf: Leaving directory `/Users/gaggina/Desktop/socket2/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
       Traceback (most recent call last):
         File "/tmp/node-node-de4o/bin/node-waf", line 16, in <module>
           Scripting.prepare(t, os.getcwd(), VERSION, wafdir)
         File "/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py", line 145, in prepare
           prepare_impl(t, cwd, ver, wafdir)
         File "/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py", line 135, in prepare_impl
           main()
         File "/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py", line 188, in main
           fun(ctx)
         File "/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py", line 386, in build
           return build_impl(bld)
         File "/tmp/node-node-de4o/bin/../lib/node/wafadmin/Scripting.py", line 405, in build_impl
           bld.compile()
         File "/tmp/node-node-de4o/bin/../lib/node/wafadmin/Build.py", line 268, in compile
           os.chdir(self.bldnode.abspath())
       OSError: [Errno 2] No such file or directory: '/Users/gaggina/Desktop/socket2/node_modules/socket.io/node_modules/redis/node_modules/hiredis/build'
       make: *** [all] Error 1
       sh: gmake: not found
       npm ERR! hiredis@0.1.14 preinstall: `make || gmake`
       npm ERR! `sh "-c" "make || gmake"` failed with 127
       npm ERR! 
       npm ERR! Failed at the hiredis@0.1.14 preinstall script.
       npm ERR! This is most likely a problem with the hiredis package,
       npm ERR! not with npm itself.
       npm ERR! Tell the author that this fails on your system:
       npm ERR!     make || gmake
       npm ERR! You can get their info via:
       npm ERR!     npm owner ls hiredis
       npm ERR! There is likely additional logging output above.

       npm ERR! System Linux 2.6.32-343-ec2
       npm ERR! command "/tmp/node-node-de4o/bin/node" "/tmp/node-npm-Xp2N/cli.js" "rebuild"
       npm ERR! cwd /tmp/build_3gzqoe2cjr234
       npm ERR! node -v v0.8.3
       npm ERR! npm -v 1.1.41
       npm ERR! code ELIFECYCLE
       npm ERR! stack Error: hiredis@0.1.14 preinstall: `make || gmake`
       npm ERR! stack `sh "-c" "make || gmake"` failed with 127
       npm ERR! stack     at ChildProcess.<anonymous> (/tmp/node-npm-Xp2N/lib/utils/exec.js:56:20)
       npm ERR! stack     at ChildProcess.EventEmitter.emit (events.js:91:17)
       npm ERR! stack     at Process._handle.onexit (child_process.js:674:10)
       npm ERR! 
       npm ERR! Additional logging details can be found in:
       npm ERR!     /tmp/build_3gzqoe2cjr234/npm-debug.log
       npm ERR! not ok code 0
 !     Failed to rebuild dependencies with npm
 !     Heroku push rejected, failed to compile Node.js app

To git@heroku.com:boiling-beyond-2052.git
 ! [remote rejected] master -> master (pre-receive hook declined)
error: failed to push some refs to 'git@heroku.com:boiling-beyond-2052.git'
[gaggina:~/Desktop/socket2]→cat /tmp/build_3gzqoe2cjr234/npm-debug.log
cat: /tmp/build_3gzqoe2cjr234/npm-debug.log: No such file or directory

解决方案

Heroku is failing to build hiredis. The reason is that hiredis (the node.js module) depends on hiredis (the C library), which needs GNU make, which is not available on your slug.

Question is, why is NPM trying to build hiredis while it's not in your dependencies ?

You should check if hiredis appears anywhere in your project (grep -R hiredis .). Another possibility is that Heroku is trying to provide redis to all node.js apps ?

I'd check with Heroku's support.

这篇关于在heroku上的socket.io + node.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆