ericholiveira / studio-cluster

Auto cluster for Studio framework
23 stars 4 forks source link

pm2 cluster support #15

Closed sean-hill closed 8 years ago

sean-hill commented 8 years ago

Hey there,

I use pm2 to deploy and monitor my applications. I'm trying out their cluster mode with my API so I can have 0 downtime on reboot. However since I'm using studio cluster I get this warning message on startup using this command:

$ pm2 start index.js -i 2

Primus: The `cluster` module does not implement sticky sessions. Learn more about
Primus: this issue at:
Primus:
Primus: http://github.com/primus/primus#can-i-use-cluster

Any suggestions here? Everything still works fine, but I don't like the warning message. Thanks.

ericholiveira commented 8 years ago

Yes... this is a warning from Primus... they strongly suggest you to dont use node "cluster" module.

If you want to remove this warning primus support a flag for this.... the flag is iknowclusterwillbreakconnections

https://github.com/primus/primus#can-i-use-cluster

To configure this you will need to pass the transport (the same way you do with publisher) , and when initializing the transport you can pass an option object, this object have up to 2 properties, one is server the other is client ... which are going to be passed for primus server and client. The you can pass it like:

{
  server:{
    iknowclusterwillbreakconnections:true
  },
  client:{
    iknowclusterwillbreakconnections:true
  }
}