Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

APP启动时可以启动一个socket server吗? #521

Closed
ghost opened this issue Mar 6, 2017 · 9 comments
Closed

APP启动时可以启动一个socket server吗? #521

ghost opened this issue Mar 6, 2017 · 9 comments

Comments

@ghost
Copy link

ghost commented Mar 6, 2017

我想在APP启动时开启自己写的socket服务,用来接收ISO-8583报文。用nodejs自带的net模块实现的。这样可以吗?

@dead-horse
Copy link
Member

dead-horse commented Mar 6, 2017

// app.js

const server = require('./server');

module.exports = app => {
  server.start();
  // 如果保证 server 启动之后再启动 egg 应用
  app.beforeStart(function*() {
    server.start();
  });
}

@atian25
Copy link
Member

atian25 commented Mar 6, 2017

要注意,agent 进程是唯一的,挂掉后不会重启,要确保错误处理。

相关 issue: #269

@dead-horse
Copy link
Member

还是放 app 上吧

@atian25
Copy link
Member

atian25 commented Mar 6, 2017

@dead-horse 放 app 的话,你那段示例是会启动多个的了

@dead-horse
Copy link
Member

启动多个也没问题,和 http server 一样

@fengmk2
Copy link
Member

fengmk2 commented Mar 6, 2017

@atian25 cluster 模块的精粹你还不够熟悉啊

@atian25
Copy link
Member

atian25 commented Mar 6, 2017

@fengmk2 回去补补课 T_T

@ghost ghost closed this as completed Mar 6, 2017
@ghost
Copy link
Author

ghost commented Mar 6, 2017

Thanks

@ghost ghost reopened this Mar 6, 2017
@ghost ghost closed this as completed Mar 6, 2017
@acodercat
Copy link

楼主最后怎么解决的呢

This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants