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

Clustering / Multi-Core Server #37

Closed
2 tasks done
Glavin001 opened this issue Jan 13, 2014 · 8 comments
Closed
2 tasks done

Clustering / Multi-Core Server #37

Glavin001 opened this issue Jan 13, 2014 · 8 comments

Comments

@Glavin001
Copy link
Contributor

Support for Cluster to create a multi-core Node.js server.

This could be a plugin for Feathers, or a built-in feature as is Socket.io and Primus.


Example of using Cluster:

Source http://adamnengland.wordpress.com/2013/01/30/node-js-cluster-with-socket-io-and-express-3/

cluster = require("cluster")
http = require("http")
numCPUs = require("os").cpus().length
RedisStore = require("socket.io/lib/stores/redis")
redis = require("socket.io/node_modules/redis")
pub = redis.createClient()
sub = redis.createClient()
client = redis.createClient()
if cluster.isMaster
  i = 0
  while i < numCPUs     cluster.fork()     i++   cluster.on 'fork', (worker) ->
    console.log 'forked worker ' + worker.process.pid
  cluster.on "listening", (worker, address) ->
    console.log "worker " + worker.process.pid + " is now connected to " + address.address + ":" + address.port
  cluster.on "exit", (worker, code, signal) ->
    console.log "worker " + worker.process.pid + " died"
else
  app = require("express")()
  server = require("http").createServer(app)
  io = require("socket.io").listen(server)
  io.set "store", new RedisStore(
    redisPub: pub
    redisSub: sub
    redisClient: client
  )
  server.listen 8000
  app.get "/", (req, res) ->
    res.sendfile(__dirname + '/index.html');
  io.sockets.on "connection", (socket) ->
    console.log 'socket call handled by worker with pid ' + process.pid
    socket.emit "news",
      hello: "world"
@ekryski
Copy link
Contributor

ekryski commented Jan 13, 2014

Are you up for providing a PR? 😄

@daffl
Copy link
Member

daffl commented Jan 13, 2014

Sounds more like a plugin to me. We had to do some work on making stuff distributed recently too, so I think providing some help there would make sense. I'll read through the article but ideas are definitely welcome.

@Glavin001
Copy link
Contributor Author

Absolutey. @ekryski. I will need a little help getting started, as I am new to Feathers and have no concept of how best to start a plugin.

@daffl, do we have a plugin repository or documentation on how to build a plugin properly for Feathers? I can get started tonight.

@daffl
Copy link
Member

daffl commented Jan 17, 2014

It'd be the first :) I'm planning put a sample plugin repository up though (to also work on #22) and I'll let you know.

@Glavin001
Copy link
Contributor Author

Awesome, thanks!

@Glavin001
Copy link
Contributor Author

For those following this issue, please watch the feathers-cluster plugin.

@Glavin001
Copy link
Contributor Author

feathers-cluster has been tested and released to NPM.

daffl pushed a commit that referenced this issue Aug 21, 2018
* bootstrap service filters

* bump minor

* add tests for filterMixin

* missing test deps
daffl pushed a commit that referenced this issue Aug 22, 2018
* bootstrap service filters

* bump minor

* add tests for filterMixin

* missing test deps
daffl pushed a commit that referenced this issue Aug 25, 2018
daffl pushed a commit that referenced this issue Aug 25, 2018
Runs semistandard on the actual generator code.
daffl pushed a commit that referenced this issue Aug 29, 2018
Fix old property name fallback for backwards compatibility
daffl pushed a commit that referenced this issue Aug 29, 2018
Check for params.provider in requireAuth hook
daffl pushed a commit that referenced this issue Aug 29, 2018
Fix old property name fallback for backwards compatibility
daffl pushed a commit that referenced this issue Aug 29, 2018
Check for params.provider in requireAuth hook
@lock
Copy link

lock bot commented Feb 8, 2019

This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue with a link to this issue for related bugs.

@lock lock bot locked as resolved and limited conversation to collaborators Feb 8, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants